-
Notifications
You must be signed in to change notification settings - Fork 1
docs: Add AWS architecture diagram and documentation #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ce33511
3fcc647
196a33b
e5e4b60
45d75c7
0bad9ce
5f51b9c
a3f4473
0ffa8ab
a6bd59a
e807885
d824a1d
aa4b964
156934d
37c7f8a
b21f767
ff1a0d0
9f1d99d
e72605e
6d4c974
2851747
5d1a159
5c8bc9e
7e5da24
1b2fece
15a40d5
4616764
a53edfa
283e35b
4b67b30
0e79606
b400800
88e7564
8b49799
ad646a3
03a5c5b
c2bb29c
9d2154a
797968f
50d0594
d21c003
5f884d9
b98f1ab
775bd50
168bb71
a1aced8
b59b21d
3b5bac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,30 +22,175 @@ permissions: | |||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||
| destroy-plan: | ||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| environment: ${{ inputs.environment }} | ||||||||||||||||||||||||||||||||||||||
| environment: Development | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - name: Placeholder - Destroy plan step | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| echo "This step is empty - destroy plan functionality not implemented on main branch" | ||||||||||||||||||||||||||||||||||||||
| echo "Environment: ${{ inputs.environment }}" | ||||||||||||||||||||||||||||||||||||||
| echo "Plan only: ${{ inputs.plan_only }}" | ||||||||||||||||||||||||||||||||||||||
| - name: Get Environment Name for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| id: get_env_name | ||||||||||||||||||||||||||||||||||||||
| uses: Entepotenz/change-string-case-action-min-dependencies@v1 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| string: ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined variable The with:
string: ${{ inputs.environment }}Adjust downstream references accordingly. 🧰 Tools🪛 YAMLlint (1.37.1)[warning] 27-27: wrong indentation: expected 4 but found 6 (indentation) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Checkout repo | ||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Checkout config repository | ||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| repository: 'speedandfunction/website-ci-secret' | ||||||||||||||||||||||||||||||||||||||
| path: 'terraform-config' | ||||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.PAT }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Copy tfvars for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| cat "terraform-config/${{ vars.ENV_NAME }}.tfvars" "deployment/environments/${{ vars.ENV_NAME }}.tfvars" > "deployment/terraform.tfvars" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect reference in tfvars copy command The 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Setup Terraform | ||||||||||||||||||||||||||||||||||||||
| uses: hashicorp/setup-terraform@v2 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| terraform_version: 1.12.0 | ||||||||||||||||||||||||||||||||||||||
| terraform_wrapper: false | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Terraform Destroy Plan for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| cd deployment | ||||||||||||||||||||||||||||||||||||||
| terraform init -backend-config="environments/backend-${{ vars.ENV_NAME }}.hcl" | ||||||||||||||||||||||||||||||||||||||
| terraform plan -destroy -out="${{ vars.ENV_NAME }}-destroy.tfplan" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use correct environment variable in Terraform init/plan commands - terraform init -backend-config="environments/backend-${{ vars.ENV_NAME }}.hcl"
- terraform plan -destroy -out="${{ vars.ENV_NAME }}-destroy.tfplan"
+ terraform init -backend-config="environments/backend-${{ inputs.environment }}.hcl"
+ terraform plan -destroy -out="${{ inputs.environment }}-destroy.tfplan"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Show Destroy Plan Summary | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| cd deployment | ||||||||||||||||||||||||||||||||||||||
| echo "## 🚨 DESTROY PLAN SUMMARY FOR ${{ vars.ENV_NAME }} 🚨" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| echo "The following resources will be **DESTROYED**:" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| terraform show -no-color "${{ vars.ENV_NAME }}-destroy.tfplan" | head -50 >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update summary step to reflect the dynamic environment - echo "## 🚨 DESTROY PLAN SUMMARY FOR ${{ vars.ENV_NAME }} 🚨" >> $GITHUB_STEP_SUMMARY
+ echo "## 🚨 DESTROY PLAN SUMMARY FOR ${{ inputs.environment }} 🚨" >> $GITHUB_STEP_SUMMARY📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Copy destroy plan to S3 bucket for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| if: ${{ inputs.plan_only == false }} | ||||||||||||||||||||||||||||||||||||||
| run: aws s3 cp "deployment/${{ vars.ENV_NAME }}-destroy.tfplan" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| SETTINGS_BUCKET: sf-website-infrastructure | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+76
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update S3 artifact paths to use the valid environment variable - run: aws s3 cp "deployment/${{ vars.ENV_NAME }}-destroy.tfplan" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan"
+ run: aws s3 cp "deployment/${{ inputs.environment }}-destroy.tfplan" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}-destroy.tfplan"
...
- run: aws s3 cp "deployment/.terraform.lock.hcl" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl"
+ run: aws s3 cp "deployment/.terraform.lock.hcl" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}.terraform.lock.hcl"Also applies to: 85-92 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Copy lock file to S3 bucket for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| if: ${{ !inputs.plan_only }} | ||||||||||||||||||||||||||||||||||||||
| run: aws s3 cp "deployment/.terraform.lock.hcl" "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| SETTINGS_BUCKET: sf-website-infrastructure | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| manual-approval: | ||||||||||||||||||||||||||||||||||||||
| needs: [destroy-plan] | ||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| environment: Development | ||||||||||||||||||||||||||||||||||||||
| if: ${{ !inputs.plan_only }} | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - name: Placeholder - Manual approval step | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| echo "This step is empty - manual approval functionality not implemented on main branch" | ||||||||||||||||||||||||||||||||||||||
| echo "Would wait for approval to destroy ${{ inputs.environment }}" | ||||||||||||||||||||||||||||||||||||||
| - name: Wait for approval to destroy ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| if: ${{ inputs.environment != 'Development' }} | ||||||||||||||||||||||||||||||||||||||
| uses: trstringer/manual-approval@v1 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| secret: ${{ github.TOKEN }} | ||||||||||||||||||||||||||||||||||||||
| approvers: killev | ||||||||||||||||||||||||||||||||||||||
| minimum-approvals: 1 | ||||||||||||||||||||||||||||||||||||||
| issue-title: "🚨 DESTROY ${{ vars.ENV_NAME }} AWS Environment 🚨" | ||||||||||||||||||||||||||||||||||||||
| issue-body: | | ||||||||||||||||||||||||||||||||||||||
| ## ⚠️ CRITICAL: Infrastructure Destruction Request ⚠️ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| **Environment**: ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| **Requested by**: @${{ github.actor }} | ||||||||||||||||||||||||||||||||||||||
| **Workflow run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ### 🚨 WARNING: This action will PERMANENTLY DESTROY the following infrastructure: | ||||||||||||||||||||||||||||||||||||||
| - VPC and all networking components | ||||||||||||||||||||||||||||||||||||||
| - ECS cluster and services | ||||||||||||||||||||||||||||||||||||||
| - DocumentDB cluster and all data | ||||||||||||||||||||||||||||||||||||||
| - ElastiCache Redis cluster and all data | ||||||||||||||||||||||||||||||||||||||
| - Application Load Balancer | ||||||||||||||||||||||||||||||||||||||
| - CloudFront distribution | ||||||||||||||||||||||||||||||||||||||
| - S3 buckets and all stored files | ||||||||||||||||||||||||||||||||||||||
| - ECR repository and all images | ||||||||||||||||||||||||||||||||||||||
| - IAM roles and policies | ||||||||||||||||||||||||||||||||||||||
| - CloudWatch logs and metrics | ||||||||||||||||||||||||||||||||||||||
| - Parameter Store secrets | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ### 📋 Before approving, please verify: | ||||||||||||||||||||||||||||||||||||||
| - [ ] This is the correct environment to destroy | ||||||||||||||||||||||||||||||||||||||
| - [ ] All important data has been backed up | ||||||||||||||||||||||||||||||||||||||
| - [ ] Team has been notified of the destruction | ||||||||||||||||||||||||||||||||||||||
| - [ ] No critical services depend on this infrastructure | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| **To approve**: Comment "approve" or "approved" | ||||||||||||||||||||||||||||||||||||||
| **To deny**: Comment "deny" or "denied" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| **⚠️ THIS ACTION CANNOT BE UNDONE ⚠️** | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| destroy-apply: | ||||||||||||||||||||||||||||||||||||||
| needs: [manual-approval] | ||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| if: ${{ !inputs.plan_only }} | ||||||||||||||||||||||||||||||||||||||
| environment: Development | ||||||||||||||||||||||||||||||||||||||
| if: ${{ inputs.plan_only == false && (inputs.environment == 'Development' || needs.manual-approval.result == 'success') }} | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - name: Placeholder - Destroy apply step | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| echo "This step is empty - destroy apply functionality not implemented on main branch" | ||||||||||||||||||||||||||||||||||||||
| echo "Would destroy infrastructure for ${{ inputs.environment }}" | ||||||||||||||||||||||||||||||||||||||
| - name: Get Environment Name for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| id: get_env_name | ||||||||||||||||||||||||||||||||||||||
| uses: Entepotenz/change-string-case-action-min-dependencies@v1 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| string: ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+143
to
+150
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix - - name: Get Environment Name for ${{ vars.ENV_NAME }}
- id: get_env_name
- uses: Entepotenz/change-string-case-action-min-dependencies@v1
- with:
- string: ${{ vars.ENV_NAME }}
+ - name: Normalize environment name
+ id: get_env_name
+ uses: Entepotenz/change-string-case-action-min-dependencies@v1
+ with:
+ string: ${{ inputs.environment }}📝 Committable suggestion
Suggested change
🧰 Tools🪛 YAMLlint (1.37.1)[warning] 142-142: wrong indentation: expected 4 but found 6 (indentation) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Setup Terraform | ||||||||||||||||||||||||||||||||||||||
| uses: hashicorp/setup-terraform@v2 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| terraform_version: 1.12.0 | ||||||||||||||||||||||||||||||||||||||
| terraform_wrapper: false | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Get destroy plan from S3 bucket for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan" "deployment/${{ vars.ENV_NAME }}-destroy.tfplan" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| SETTINGS_BUCKET: sf-website-infrastructure | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+167
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use valid environment reference for S3 download steps - run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan" "deployment/${{ vars.ENV_NAME }}-destroy.tfplan"
+ run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}-destroy.tfplan" "deployment/${{ inputs.environment }}-destroy.tfplan"
...
- run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl" "deployment/.terraform.lock.hcl"
+ run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}.terraform.lock.hcl" "deployment/.terraform.lock.hcl"Also applies to: 165-172 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| - name: Get lock file from S3 bucket for ${{ vars.ENV_NAME }} | ||||||||||||||||||||||||||||||||||||||
| run: aws s3 cp "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl" "deployment/.terraform.lock.hcl" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| SETTINGS_BUCKET: sf-website-infrastructure | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: 🚨 DESTROY Infrastructure for ${{ vars.ENV_NAME }} 🚨 | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| cd deployment | ||||||||||||||||||||||||||||||||||||||
| terraform init -backend-config="environments/backend-${{ vars.ENV_NAME }}.hcl" | ||||||||||||||||||||||||||||||||||||||
| echo "🚨 DESTROYING INFRASTRUCTURE FOR ${{ vars.ENV_NAME }} - THIS CANNOT BE UNDONE! 🚨" | ||||||||||||||||||||||||||||||||||||||
| terraform apply "${{ vars.ENV_NAME }}-destroy.tfplan" | ||||||||||||||||||||||||||||||||||||||
| echo "✅ Infrastructure for ${{ vars.ENV_NAME }} has been destroyed" | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Clean up destroy plan files | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan" || true | ||||||||||||||||||||||||||||||||||||||
| aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl" || true | ||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID: ${{ secrets.TF_AWS_ACCESS_KEY_ID }} | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||||||||||||||||||||||||
| SETTINGS_BUCKET: sf-website-infrastructure | ||||||||||||||||||||||||||||||||||||||
| AWS_DEFAULT_REGION: "us-east-1" | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+188
to
+196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix cleanup step to reference the valid environment variable - aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}-destroy.tfplan" || true
- aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ vars.ENV_NAME }}.terraform.lock.hcl" || true
+ aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}-destroy.tfplan" || true
+ aws s3 rm "s3://${{ env.SETTINGS_BUCKET }}/destroy-plans/${{ inputs.environment }}.terraform.lock.hcl" || true📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/bin/bash | ||
|
|
||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enable full strict mode for safer Bash execution. Currently the script uses set -euo pipefailto ensure the script exits on errors, undefined variables, and any command in a pipeline. 🤖 Prompt for AI Agents |
||
| # ECS Deployment Script | ||
| # This script rebuilds the Docker image, pushes it to ECR, and restarts the ECS service | ||
|
|
||
| set -e # Exit on any error | ||
|
|
||
| # Configuration | ||
| AWS_PROFILE="tf-sf-website" | ||
| AWS_REGION="us-east-1" | ||
| ECR_REPOSITORY="695912022152.dkr.ecr.us-east-1.amazonaws.com/sf-website-development" | ||
| ECS_CLUSTER="sf-website-dev-cluster" | ||
| ECS_SERVICE="sf-website-dev-service" | ||
| IMAGE_TAG="latest" | ||
|
|
||
| echo "🚀 Starting ECS deployment process..." | ||
|
|
||
| # Step 1: Login to ECR | ||
| echo "📝 Logging into ECR..." | ||
| AWS_PROFILE=$AWS_PROFILE aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REPOSITORY | ||
|
|
||
| # Step 2: Build the Docker image | ||
| echo "🔨 Building Docker image for linux/amd64 platform..." | ||
| docker build --platform linux/amd64 -t $ECR_REPOSITORY:$IMAGE_TAG . | ||
|
|
||
| # Step 3: Push the image to ECR | ||
| echo "📤 Pushing image to ECR..." | ||
| docker push $ECR_REPOSITORY:$IMAGE_TAG | ||
|
|
||
| # Step 4: Force ECS service to restart with new image | ||
| echo "🔄 Restarting ECS service..." | ||
| AWS_PROFILE=$AWS_PROFILE aws ecs update-service \ | ||
| --cluster $ECS_CLUSTER \ | ||
| --service $ECS_SERVICE \ | ||
| --force-new-deployment \ | ||
| --region $AWS_REGION | ||
|
|
||
| # Step 5: Wait for deployment to complete | ||
| echo "⏳ Waiting for deployment to complete..." | ||
| AWS_PROFILE=$AWS_PROFILE aws ecs wait services-stable \ | ||
| --cluster $ECS_CLUSTER \ | ||
| --services $ECS_SERVICE \ | ||
| --region $AWS_REGION | ||
|
|
||
| echo "✅ Deployment completed successfully!" | ||
| echo "🌐 Your application should be available at: https://sf-website-dev.sandbox-prettyclear.com" | ||
|
Comment on lines
+45
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid hard-coded URLs for environment-specific outputs. The final echo prints a fixed dev URL. For staging or production this will be incorrect. 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded environment context
The job uses
environment: Developmentstatically. To honor the user’s input, change this to:so the workflow dynamically targets the selected environment.
🤖 Prompt for AI Agents