-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update private subnets so they can pull from ecr * add tfstate module * update setup to use a module for state and oidc management additions * update docs * update deployment to be more configurable via secrets and variables * add a plan workflow * Add max and min capacity for future autoscaling options * separate out github workflows, typo and description updates * update docs to include suggestions for directory/environment management
- Loading branch information
Showing
25 changed files
with
512 additions
and
265 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Terraform Apply | ||
run-name: Terraform ${{ inputs.terraform_action }} ${{ inputs.workspace }} by @${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
workspace: | ||
description: 'The workspace to terraform against' | ||
required: true | ||
type: choice | ||
options: | ||
- "" | ||
- prod | ||
|
||
concurrency: | ||
group: ${{ github.event.inputs.workspace }}-terraform | ||
cancel-in-progress: false | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
workspace: ${{ github.event.inputs.workspace }} | ||
terraform_action: apply | ||
|
||
jobs: | ||
terraform: | ||
name: Run Terraform | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
# this may need to be updated if you change the directory you are working with | ||
# ./terraform/implementation/dev || ./terraform/implementation/prod for example | ||
# this practice is recommended to keep the terraform code organized while reducing the risk of conflicts | ||
working-directory: ./terraform/implementation/ecs | ||
steps: | ||
- name: Check Out Changes | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
|
||
- name: configure aws credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
role-session-name: githubDeploymentWorkflow | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Terraform | ||
env: | ||
ACTION: ${{ env.terraform_action }} | ||
BUCKET: ${{ secrets.TFSTATE_BUCKET }} | ||
DYNAMODB_TABLE: ${{ secrets.TFSTATE_DYNAMODB_TABLE }} | ||
OWNER: ${{ vars.OWNER }} | ||
PROJECT: ${{ vars.PROJECT }} | ||
REGION: ${{ vars.AWS_REGION }} | ||
WORKSPACE: ${{ env.workspace }} | ||
shell: bash | ||
run: | | ||
echo "owner = \"$OWNER\"" >> $WORKSPACE.tfvars | ||
echo "project = \"$PROJECT\"" >> $WORKSPACE.tfvars | ||
echo "region = \"$REGION\"" >> $WORKSPACE.tfvars | ||
terraform init \ | ||
-var-file="$WORKSPACE.tfvars" \ | ||
-backend-config "bucket=$BUCKET" \ | ||
-backend-config "dynamodb_table=$DYNAMODB_TABLE" \ | ||
-backend-config "region=$REGION" \ | ||
|| (echo "terraform init failed, exiting..." && exit 1) | ||
terraform workspace select "$WORKSPACE" | ||
terraform apply -auto-approve -var-file="$WORKSPACE.tfvars" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Terraform Plan | ||
run-name: Terraform ${{ inputs.terraform_action }} ${{ inputs.workspace }} by @${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
workspace: | ||
description: 'The workspace to terraform against' | ||
required: true | ||
type: choice | ||
options: | ||
- "" | ||
- prod | ||
|
||
concurrency: | ||
group: ${{ github.event.inputs.workspace }}-terraform | ||
cancel-in-progress: false | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
workspace: ${{ github.event.inputs.workspace }} | ||
terraform_action: plan | ||
|
||
jobs: | ||
terraform: | ||
name: Run Terraform | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
# this may need to be updated if you change the directory you are working with | ||
# ./terraform/implementation/dev || ./terraform/implementation/prod for example | ||
# this practice is recommended to keep the terraform code organized while reducing the risk of conflicts | ||
working-directory: ./terraform/implementation/ecs | ||
steps: | ||
- name: Check Out Changes | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
|
||
- name: configure aws credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
role-session-name: githubDeploymentWorkflow | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Terraform | ||
env: | ||
ACTION: ${{ env.terraform_action }} | ||
BUCKET: ${{ secrets.TFSTATE_BUCKET }} | ||
DYNAMODB_TABLE: ${{ secrets.TFSTATE_DYNAMODB_TABLE }} | ||
OWNER: ${{ vars.OWNER }} | ||
PROJECT: ${{ vars.PROJECT }} | ||
REGION: ${{ vars.AWS_REGION }} | ||
WORKSPACE: ${{ env.workspace }} | ||
shell: bash | ||
run: | | ||
echo "owner = \"$OWNER\"" >> $WORKSPACE.tfvars | ||
echo "project = \"$PROJECT\"" >> $WORKSPACE.tfvars | ||
echo "region = \"$REGION\"" >> $WORKSPACE.tfvars | ||
terraform init \ | ||
-var-file="$WORKSPACE.tfvars" \ | ||
-backend-config "bucket=$BUCKET" \ | ||
-backend-config "dynamodb_table=$DYNAMODB_TABLE" \ | ||
-backend-config "region=$REGION" \ | ||
|| (echo "terraform init failed, exiting..." && exit 1) | ||
terraform workspace select "$WORKSPACE" | ||
terraform plan -var-file="$WORKSPACE.tfvars" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.