Skip to content

Commit 703ebac

Browse files
Merge pull request #1 from chrispsheehan/lambda-api-infra
feat: lambda api infra
2 parents cafd35a + 34b568d commit 703ebac

File tree

19 files changed

+209
-26
lines changed

19 files changed

+209
-26
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ on:
88
required: true
99
type: string
1010
outputs:
11-
web_bucket:
12-
description: "Bucket containing static website files"
13-
value: ${{ jobs.infra.outputs.web_bucket_name }}
1411
lambda_bucket:
1512
description: "Bucket containing lambda zips"
1613
value: ${{ jobs.infra.outputs.lambda_bucket_name }}
14+
lambda_version:
15+
description: "Valid lambda version"
16+
value: ${{ inputs.version }}
1717

1818
concurrency: # only run one instance of workflow at any one time
1919
group: ${{ github.workflow }}-${{inputs.environment}}

.github/workflows/deploy.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828
contents: write
2929

3030
env:
31-
TF_VAR_deploy_version: ${{ inputs.lambda_version }}
31+
TF_VAR_lambda_version: ${{ inputs.lambda_version }}
3232
AWS_OIDC_ROLE_ARN: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/aws-serverless-github-deploy-${{ inputs.environment }}-github-oidc-role
3333

3434
jobs:
@@ -61,3 +61,18 @@ jobs:
6161
with:
6262
aws_oidc_role_arn: ${{ env.AWS_OIDC_ROLE_ARN }}
6363
just_action: check-version
64+
65+
api:
66+
needs:
67+
- oidc
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
with:
72+
ref: ${{ inputs.infra_version }}
73+
74+
- name: Deploy API
75+
uses: chrispsheehan/terragrunt-aws-oidc-action@0.4.0
76+
with:
77+
aws_oidc_role_arn: ${{ env.AWS_OIDC_ROLE_ARN }}
78+
tg_directory: infra/live/${{ inputs.environment }}/aws/api

.github/workflows/destroy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ permissions:
1919
contents: write
2020

2121
env:
22-
TF_VAR_deploy_version: this
22+
TF_VAR_lambda_version: this
2323
AWS_OIDC_ROLE_ARN: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/aws-serverless-github-deploy-${{ inputs.environment }}-github-oidc-role
2424

2525
jobs:
26-
backend:
26+
api:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
@@ -32,12 +32,12 @@ jobs:
3232
uses: chrispsheehan/terragrunt-aws-oidc-action@0.4.0
3333
with:
3434
aws_oidc_role_arn: ${{ env.AWS_OIDC_ROLE_ARN }}
35-
tg_directory: infra/live/${{ inputs.environment }}/aws/jobs
35+
tg_directory: infra/live/${{ inputs.environment }}/aws/api
3636
tg_action: destroy
3737

3838
build:
3939
needs:
40-
- backend
40+
- api
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: actions/checkout@v4

.github/workflows/dev_deploy.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@ jobs:
1414
environment: dev
1515
version: ${{ github.sha }}
1616

17-
get:
18-
needs: build
19-
uses: ./.github/workflows/get_build.yml
20-
with:
21-
environment: dev
22-
version: ${{ github.sha }}
23-
2417
dev:
2518
uses: ./.github/workflows/deploy.yml
26-
needs: get
19+
needs: build
2720
with:
2821
environment: dev
2922
infra_version: ${{ github.sha }}
30-
lambda_bucket: ${{ needs.get.outputs.lambda_bucket }}
31-
lambda_version: ${{ needs.get.outputs.lambda_version }}
23+
lambda_bucket: ${{ needs.build.outputs.lambda_bucket }}
24+
lambda_version: ${{ needs.build.outputs.lambda_version }}

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# aws-serverless-github-deploy
1+
# aws-serverless-github-deploy
2+
3+
## setup roles for ci
4+
5+
```sh
6+
just tg ci aws/oidc apply
7+
just tg dev aws/oidc apply
8+
just tg prod aws/oidc apply
9+
```
10+
11+
## local plan some infra
12+
13+
Given a terragrunt file is found at `infra/live/dev/aws/api/terragrunt.hcl`
14+
15+
```sh
16+
just tg dev aws/api plan
17+
```

infra/live/ci/aws/code_bucket/terragrunt.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ include {
33
}
44

55
terraform {
6-
source = "../../../../modules/aws/code_bucket"
6+
source = "../../../../modules//aws//code_bucket"
77
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include {
2+
path = find_in_parent_folders("root.hcl")
3+
}
4+
5+
terraform {
6+
source = "../../../../modules//aws//api"
7+
}

infra/live/dev/aws/code_bucket/terragrunt.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ include {
33
}
44

55
terraform {
6-
source = "../../../../modules/aws/code_bucket"
6+
source = "../../../../modules//aws//code_bucket"
77
}

infra/live/global_vars.hcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ locals {
44
"s3:*",
55
"iam:*",
66
"lambda:*",
7-
"logs:*"
7+
"logs:*",
8+
"apigateway:*"
89
]
910
}
1011

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include {
2+
path = find_in_parent_folders("root.hcl")
3+
}
4+
5+
terraform {
6+
source = "../../../../modules//aws//api"
7+
}

0 commit comments

Comments
 (0)