Skip to content

Commit 87ef431

Browse files
authored
sync(integration): aws-lambda-aws-iam (#1)
FolderOrigin-RevId: /home/runner/work/integrations/integrations/.
1 parent fc5ee29 commit 87ef431

File tree

7 files changed

+220
-201
lines changed

7 files changed

+220
-201
lines changed

.github/workflows/deploy.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: deploy.webhook
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
env:
9+
AWS_REGION: us-west-2
10+
jobs:
11+
terraform:
12+
name: Terraform
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Setup Terraform
18+
uses: hashicorp/setup-terraform@v1
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v1
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
25+
aws-region: ${{ env.AWS_REGION }}
26+
- name: Add profile credentials to ~/.aws/credentials
27+
run: |
28+
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile default
29+
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile default
30+
aws configure set aws_region ${{ env.AWS_REGION }} --profile default
31+
- name: Terraform Format
32+
id: fmt
33+
run: terraform fmt -check -diff
34+
- name: Terraform Init
35+
id: init
36+
run: terraform init
37+
- name: Terraform Plan
38+
id: plan
39+
if: github.event_name == 'pull_request'
40+
run: terraform plan -input=false -no-color
41+
continue-on-error: true
42+
env:
43+
TF_VAR_indent_webhook_secret: ${{ secrets.INDENT_WEBHOOK_SECRET }}
44+
TF_VAR_default_user_pw: ${{ secrets.DEFAULT_USER_PW }}
45+
- uses: actions/github-script@0.9.0
46+
if: github.event_name == 'pull_request'
47+
env:
48+
PLAN: |-
49+
terraform
50+
${{ steps.plan.outputs.stdout }}
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
script: |
54+
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
55+
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
56+
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
57+
<details><summary>Show Plan</summary>
58+
\`\`\`${process.env.PLAN}\`\`\`
59+
</details>
60+
*Actor: @${{ github.actor }}, Event: \`${{ github.event_name }}\`*`;
61+
github.issues.createComment({
62+
issue_number: context.issue.number,
63+
owner: context.repo.owner,
64+
repo: context.repo.repo,
65+
body: output
66+
})
67+
- name: Terraform Plan Status
68+
if: steps.plan.outcome == 'failure'
69+
run: exit 1
70+
- name: Terraform Apply
71+
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
72+
run: terraform apply -input=false -auto-approve
73+
env:
74+
TF_VAR_indent_webhook_secret: ${{ secrets.INDENT_WEBHOOK_SECRET }}
75+
TF_VAR_default_user_pw: ${{ secrets.DEFAULT_USER_PW }}
76+
- name: Terraform Output
77+
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
78+
run: terraform output
79+
env:
80+
TF_VAR_indent_webhook_secret: ${{ secrets.INDENT_WEBHOOK_SECRET }}
81+
TF_VAR_example_api_key: ${{ secrets.EXAMPLE_API_KEY}}

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
data
2+
dist
3+
lib
4+
.env
5+
node_modules
6+
*.tfstate
7+
.terraform*
8+
*.tfstate.*
9+
terraform/config/*.tfvars
10+
!terraform/config/example.tfvars
11+
yarn.lock
12+
package-lock.json

LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Indent + AWS Lambda and AWS IAM
2+
3+
This repository contains an integration between AWS IAM and [Indent](https://indent.com). Once deployed, you will be able to use this integration with Indent to:
4+
5+
- PullUpdate
6+
- ApplyPullUpdate
7+
8+
## Quicklinks
9+
10+
- [Indent Documentation](https://indent.com/docs)
11+
- [Indent Support](https://support.indent.com)
12+
13+
**In this repo**
14+
15+
- [GitHub Secrets](./settings/secrets/actions)
16+
- [GitHub Actions](./actions/workflows/deploy.yaml)
17+
18+
## Configuration
19+
20+
Before you deploy these webhooks for the first time, [create an S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html) to store Terraform state, add your credentials as [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets), then update the bucket in `main.tf` once you're done.
21+
22+
<details><summary><strong>1. Configuring the S3 bucket</strong></summary>
23+
<p>
24+
25+
- [Go to AWS S3](https://s3.console.aws.amazon.com/s3/buckets) and select an existing bucket or create a new one.
26+
- Select the settings given your environment:
27+
- Name — easily identifiable name for the bucket (example = indent-deploy-state-123)
28+
- Region — where you plan to deploy the Lambda (default = us-west-2)
29+
- Bucket versioning — if you want to have revisions of past deployments (default = disabled)
30+
- Default encryption — server-side encryption for deployment files (default = Enable)
31+
32+
</p>
33+
</details>
34+
35+
<details><summary><strong>2. Configuring AWS credentials</strong></summary>
36+
<p>
37+
38+
- [Go to AWS IAM → New User](https://console.aws.amazon.com/iam/home#/users$new?step=details) and create a new user for deploys, e.g. `indent-terraform-deployer`
39+
- Configure the service account access:
40+
- Credential type — select **Access key - Programmatic access**
41+
- Permissions — select **Attach existing policies directly** and select `AdministratorAccess`
42+
- Add the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` as GitHub Secrets to this repo
43+
44+
</p>
45+
</details>
46+
47+
<details><summary><strong>3. Connecting to AWS IAM</strong></summary>
48+
49+
50+
</details>
51+
52+
<details><summary><strong>4. Connecting to Indent</strong></summary>
53+
54+
- If you're setting up as part of a catalog flow, you should be presented a **Webhook Secret** or [go to your Indent space and create a webhook](https://indent.com/spaces?next=/manage/spaces/[space]/webhooks/new)
55+
- Add this as `INDENT_WEBHOOK_SECRET` as a GitHub Secret
56+
57+
</details>
58+
59+
<details><summary><strong>5. Deploy</strong></summary>
60+
61+
- Enter the bucket you created in `main.tf` in the `backend` configuration
62+
- This will automatically kick off a deploy, or you can [manually trigger from GitHub Actions](./actions/workflows/terraform.yml)
63+
64+
</details>
65+
66+
### Actions secrets
67+
68+
Visit <a href="https://indent.com/docs" target="_blank">this link</a> to our documentation for information on setting up GitHub Secrets in this repository.
69+
70+
## Deployment
71+
72+
This repository auto-deploys to AWS Lambda when you push or merge PRs to the `main` branch. You can manually redeploy the webhooks by re-running the [latest GitHub Action job](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs).

0 commit comments

Comments
 (0)