-
Notifications
You must be signed in to change notification settings - Fork 6
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
add new separate terraform plans for staging and production #309
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e09154d
add new terraform plan for staging
sastels 6e0479f
Merge branch 'main' into new-terraform-plan-action
sastels c3fd7d4
bump the terragrunt version
sastels 698a79d
poke lambda to trigger action
sastels ebb40f6
fix Max's hackery
sastels 73e4909
revert lambda poke and fix formatting :sweat_smile:
sastels 67edcd5
delete unused variable
sastels e205d05
add production terraform plan workflow
sastels c1ae978
add infrastructure_version maybe
sastels 64adb9e
this might work
sastels c51a774
fix names in prod plan
sastels 1ef19f5
run the plan for common too
sastels 33cc1be
add missing variables
sastels 4cd15da
only run prod plan if infrastructure version changes
sastels 6e42513
fix typo in prod plan
sastels 261e89a
add varaiable to stop recreating the slack lambdas
sastels 366561b
Merge branch 'main' into new-terraform-plan-action
sastels b3a378f
Merge branch 'main' into new-terraform-plan-action
sastels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,165 @@ | ||
name: "Terragrunt plan PRODUCTION" | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "aws/**" | ||
- "env/production/**" | ||
- "env/terragrunt.hcl" | ||
- ".github/workflows/terragrunt_plan_production.yml" | ||
|
||
env: | ||
TARGET_ENV_PATH: production | ||
AWS_ACCESS_KEY_ID: ${{ secrets.PRODUCTION_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ca-central-1 | ||
TERRAFORM_VERSION: 0.14.4 | ||
TERRAGRUNT_VERSION: 0.31.0 | ||
TF_VAR_rds_cluster_password: ${{ secrets.PRODUCTION_RDS_CLUSTER_PASSWORD }} | ||
TF_VAR_cloudwatch_opsgenie_alarm_webhook: ${{ secrets.PRODUCTION_CLOUDWATCH_OPSGENIE_ALARM_WEBHOOK }} | ||
TF_VAR_cloudwatch_slack_webhook_warning_topic: ${{ secrets.PRODUCTION_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_cloudwatch_slack_webhook_critical_topic: ${{ secrets.PRODUCTION_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_cloudwatch_slack_webhook_general_topic: ${{ secrets.PRODUCTION_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_slack_channel_warning_topic: notification-ops | ||
TF_VAR_slack_channel_critical_topic: notification-ops | ||
TF_VAR_slack_channel_general_topic: notification-ops | ||
TF_VAR_admin_client_secret: ${{ secrets.PRODUCTION_ADMIN_CLIENT_SECRET }} | ||
TF_VAR_admin_client_user_name: ${{ secrets.PRODUCTION_ADMIN_CLIENT_USER_NAME }} | ||
TF_VAR_api_host_name: ${{ secrets.PRODUCTION_API_HOST_NAME }} | ||
TF_VAR_asset_domain: ${{ secrets.PRODUCTION_ASSET_DOMAIN }} | ||
TF_VAR_asset_upload_bucket_name: ${{ secrets.PRODUCTION_ASSET_UPLOAD_BUCKET_NAME }} | ||
TF_VAR_auth_tokens: ${{ secrets.PRODUCTION_AUTH_TOKENS }} | ||
TF_VAR_base_domain: ${{ secrets.PRODUCTION_BASE_DOMAIN }} | ||
TF_VAR_csv_upload_bucket_name: ${{ secrets.PRODUCTION_CSV_UPLOAD_BUCKET_NAME }} | ||
TF_VAR_dangerous_salt: ${{ secrets.PRODUCTION_DANGEROUS_SALT }} | ||
TF_VAR_documents_bucket: ${{ secrets.PRODUCTION_DOCUMENTS_BUCKET }} | ||
TF_VAR_document_download_api_host: ${{ secrets.PRODUCTION_DOCUMENT_DOWNLOAD_API_HOST }} | ||
TF_VAR_mlwr_host: "false" | ||
TF_VAR_notification_queue_prefix: eks-notification-canada-ca | ||
TF_VAR_redis_url: ${{ secrets.PRODUCTION_REDIS_URL }} | ||
TF_VAR_secret_key: ${{ secrets.PRODUCTION_SECRET_KEY }} | ||
TF_VAR_sqlalchemy_database_reader_uri: ${{ secrets.PRODUCTION_SQLALCHEMY_DATABASE_READER_URI }} | ||
TF_VAR_sqlalchemy_database_uri: ${{ secrets.PRODUCTION_SQLALCHEMY_DATABASE_URI }} | ||
|
||
jobs: | ||
terragrunt-plan-production: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@3d8debd658c92063839bc97da5c2427100420dec # v1.3.2 | ||
with: | ||
terraform_version: ${{ env.TERRAFORM_VERSION }} | ||
terraform_wrapper: false | ||
|
||
- name: Setup Terragrunt | ||
run: | | ||
mkdir bin | ||
wget -O bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v$TERRAGRUNT_VERSION/terragrunt_linux_amd64 | ||
chmod +x bin/* | ||
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | ||
|
||
- name: Set INFRASTRUCTURE_VERSION | ||
run: | | ||
INFRASTRUCTURE_VERSION=`cat ./.github/workflows/infrastructure_version.txt` | ||
echo "INFRASTRUCTURE_VERSION=$INFRASTRUCTURE_VERSION" >> $GITHUB_ENV | ||
|
||
- uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721 # v2.10.2 | ||
id: filter | ||
with: | ||
filters: | | ||
common: | ||
- '.github/workflows/terragrunt-plan-production.yml' | ||
- 'env/common/**' | ||
- 'env/terragrunt.hcl' | ||
- 'env/production/env_vars.hcl' | ||
dns: | ||
- 'aws/dns/**' | ||
- 'env/production/dns/**' | ||
eks: | ||
- 'aws/eks/**' | ||
- 'env/production/eks/**' | ||
elasticache: | ||
- 'aws/elasticache/**' | ||
- 'env/production/elasticache/**' | ||
rds: | ||
- 'aws/rds/**' | ||
- 'env/production/rds/**' | ||
cloudfront: | ||
- 'aws/cloudfront/**' | ||
- 'env/production/cloudfront/**' | ||
lambda-api: | ||
- 'aws/lambda-api/**' | ||
- 'env/production/lambda-api/**' | ||
|
||
- name: Terragrunt plan common | ||
if: ${{ steps.filter.outputs.common == 'true }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/common" | ||
comment-delete: "true" | ||
comment-title: "Production: common" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan dns | ||
if: ${{ steps.filter.outputs.dns == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/dns" | ||
comment-delete: "true" | ||
comment-title: "Production: dns" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
- name: Terragrunt plan eks | ||
if: ${{ steps.filter.outputs.eks == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/eks" | ||
comment-delete: "true" | ||
comment-title: "Production: eks" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan elasticache | ||
if: ${{ steps.filter.outputs.elasticache == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/elasticache" | ||
comment-delete: "true" | ||
comment-title: "Production: elasticache" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan rds | ||
if: ${{ steps.filter.outputs.rds == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/rds" | ||
comment-delete: "true" | ||
comment-title: "Production: rds" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan cloudfront | ||
if: ${{ steps.filter.outputs.cloudfront == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/cloudfront" | ||
comment-delete: "true" | ||
comment-title: "Production: cloudfront" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan lambda-api | ||
if: ${{ steps.filter.outputs.lambda-api == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/production/lambda-api" | ||
comment-delete: "true" | ||
comment-title: "Production: lambda-api" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" |
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,160 @@ | ||
name: "Terragrunt plan STAGING" | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "aws/**" | ||
- "env/staging/**" | ||
- "env/terragrunt.hcl" | ||
- ".github/workflows/terragrunt_plan_staging.yml" | ||
|
||
env: | ||
TARGET_ENV_PATH: staging | ||
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ca-central-1 | ||
TERRAFORM_VERSION: 0.14.4 | ||
TERRAGRUNT_VERSION: 0.31.0 | ||
TF_VAR_rds_cluster_password: ${{ secrets.STAGING_RDS_CLUSTER_PASSWORD }} | ||
TF_VAR_cloudwatch_opsgenie_alarm_webhook: "" | ||
TF_VAR_cloudwatch_slack_webhook_warning_topic: ${{ secrets.STAGING_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_cloudwatch_slack_webhook_critical_topic: ${{ secrets.STAGING_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_cloudwatch_slack_webhook_general_topic: ${{ secrets.STAGING_CLOUDWATCH_SLACK_WEBHOOK }} | ||
TF_VAR_slack_channel_warning_topic: "notification-staging-ops" | ||
TF_VAR_slack_channel_critical_topic: "notification-staging-ops" | ||
TF_VAR_slack_channel_general_topic: "notification-staging-ops" | ||
TF_VAR_admin_client_secret: ${{ secrets.STAGING_ADMIN_CLIENT_SECRET }} | ||
TF_VAR_admin_client_user_name: ${{ secrets.STAGING_ADMIN_CLIENT_USER_NAME }} | ||
TF_VAR_api_host_name: ${{ secrets.STAGING_API_HOST_NAME }} | ||
TF_VAR_asset_domain: ${{ secrets.STAGING_ASSET_DOMAIN }} | ||
TF_VAR_asset_upload_bucket_name: ${{ secrets.STAGING_ASSET_UPLOAD_BUCKET_NAME }} | ||
TF_VAR_auth_tokens: ${{ secrets.STAGING_AUTH_TOKENS }} | ||
TF_VAR_base_domain: ${{ secrets.STAGING_BASE_DOMAIN }} | ||
TF_VAR_csv_upload_bucket_name: ${{ secrets.STAGING_CSV_UPLOAD_BUCKET_NAME }} | ||
TF_VAR_dangerous_salt: ${{ secrets.STAGING_DANGEROUS_SALT }} | ||
TF_VAR_documents_bucket: ${{ secrets.STAGING_DOCUMENTS_BUCKET }} | ||
TF_VAR_document_download_api_host: ${{ secrets.STAGING_DOCUMENT_DOWNLOAD_API_HOST }} | ||
TF_VAR_mlwr_host: "false" | ||
TF_VAR_notification_queue_prefix: eks-notification-canada-ca | ||
TF_VAR_redis_url: ${{ secrets.STAGING_REDIS_URL }} | ||
TF_VAR_secret_key: ${{ secrets.STAGING_SECRET_KEY }} | ||
TF_VAR_sqlalchemy_database_reader_uri: ${{ secrets.STAGING_SQLALCHEMY_DATABASE_READER_URI }} | ||
TF_VAR_sqlalchemy_database_uri: ${{ secrets.STAGING_SQLALCHEMY_DATABASE_URI }} | ||
|
||
jobs: | ||
terragrunt-plan-staging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@3d8debd658c92063839bc97da5c2427100420dec # v1.3.2 | ||
with: | ||
terraform_version: ${{ env.TERRAFORM_VERSION }} | ||
terraform_wrapper: false | ||
|
||
- name: Setup Terragrunt | ||
run: | | ||
mkdir bin | ||
wget -O bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v$TERRAGRUNT_VERSION/terragrunt_linux_amd64 | ||
chmod +x bin/* | ||
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | ||
- uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721 # v2.10.2 | ||
id: filter | ||
with: | ||
filters: | | ||
common: | ||
- '.github/workflows/terragrunt-plan-staging.yml' | ||
- 'env/common/**' | ||
- 'env/terragrunt.hcl' | ||
- 'env/staging/env_vars.hcl' | ||
dns: | ||
- 'aws/dns/**' | ||
- 'env/staging/dns/**' | ||
eks: | ||
- 'aws/eks/**' | ||
- 'env/staging/eks/**' | ||
elasticache: | ||
- 'aws/elasticache/**' | ||
- 'env/staging/elasticache/**' | ||
rds: | ||
- 'aws/rds/**' | ||
- 'env/staging/rds/**' | ||
cloudfront: | ||
- 'aws/cloudfront/**' | ||
- 'env/staging/cloudfront/**' | ||
lambda-api: | ||
- 'aws/lambda-api/**' | ||
- 'env/staging/lambda-api/**' | ||
|
||
- name: Terragrunt plan common | ||
if: ${{ steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/common" | ||
comment-delete: "true" | ||
comment-title: "Staging: common" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan dns | ||
if: ${{ steps.filter.outputs.dns == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/dns" | ||
comment-delete: "true" | ||
comment-title: "Staging: dns" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan eks | ||
if: ${{ steps.filter.outputs.eks == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/eks" | ||
comment-delete: "true" | ||
comment-title: "Staging: eks" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan elasticache | ||
if: ${{ steps.filter.outputs.elasticache == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/elasticache" | ||
comment-delete: "true" | ||
comment-title: "Staging: elasticache" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan rds | ||
if: ${{ steps.filter.outputs.rds == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/rds" | ||
comment-delete: "true" | ||
comment-title: "Staging: rds" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan cloudfront | ||
if: ${{ steps.filter.outputs.cloudfront == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/cloudfront" | ||
comment-delete: "true" | ||
comment-title: "Staging: cloudfront" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" | ||
|
||
- name: Terragrunt plan lambda-api | ||
if: ${{ steps.filter.outputs.lambda-api == 'true' || steps.filter.outputs.common == 'true' }} | ||
uses: cds-snc/terraform-plan@v1 | ||
with: | ||
directory: "env/staging/lambda-api" | ||
comment-delete: "true" | ||
comment-title: "Staging: lambda-api" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
terragrunt: "true" |
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
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 |
---|---|---|
|
@@ -6,13 +6,9 @@ variable "kms_arn" { | |
type = string | ||
} | ||
|
||
variable "rds_server_db_user" { | ||
type = string | ||
} | ||
|
||
Comment on lines
-9
to
-12
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. 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. Thanks for cleaning it up. |
||
variable "rds_cluster_password" { | ||
type = string | ||
sensitive = true | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "rds_instance_count" { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To cut down on PR noise, it might make sense to set this to the same triggers as the
merge_to_main_production.yml
paths:https://github.com/cds-snc/notification-terraform/blob/main/.github/workflows/merge_to_main_production.yml#L8-L10
That way you only see Prod plan comments if you're expecting to have
terraform apply
run against Prod when you merge.