Skip to content

Commit f873f10

Browse files
committed
run terraform on deploy to QA
1 parent 2e9b192 commit f873f10

File tree

9 files changed

+51
-41
lines changed

9 files changed

+51
-41
lines changed

.github/workflows/deploy-qa.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
env:
2121
HUSKY: "0"
2222

23+
- name: Setup Terraform
24+
uses: hashicorp/setup-terraform@v2
25+
with:
26+
terraform_version: 1.12.2
27+
28+
2329
- name: Set up Node
2430
uses: actions/setup-node@v4
2531
with:
@@ -102,6 +108,11 @@ jobs:
102108
node-version: 22.x
103109
cache: "yarn"
104110

111+
- name: Setup Terraform
112+
uses: hashicorp/setup-terraform@v2
113+
with:
114+
terraform_version: 1.12.2
115+
105116
- name: Restore Yarn Cache
106117
uses: actions/cache@v4
107118
with:

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ deploy_prod: check_account_prod
9696
deploy_dev: check_account_dev
9797
@echo "Deploying CloudFormation stack..."
9898
sam deploy $(common_params) --parameter-overrides $(run_env)=dev $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)"
99+
@echo "Deploying Terraform..."
100+
terraform -chdir=terraform/envs/qa apply -auto-approve
99101
make postdeploy
100102

101103
invalidate_cloudfront:
@@ -121,6 +123,10 @@ test_live_integration: install
121123
test_unit: install
122124
yarn lint
123125
cfn-lint cloudformation/**/*
126+
terraform -chdir=terraform/envs/qa fmt -check
127+
terraform -chdir=terraform/envs/prod fmt -check
128+
terraform -chdir=terraform/envs/qa validate
129+
terraform -chdir=terraform/envs/prod validate
124130
yarn prettier
125131
yarn test:unit
126132

cloudformation/logs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Resources:
1111
AppApiLambdaLogGroup:
1212
Type: AWS::Logs::LogGroup
1313
DeletionPolicy: Retain
14+
UpdateReplacePolicy: Retain
1415
Properties:
1516
LogGroupName:
1617
Fn::Sub: /aws/lambda/${LambdaFunctionName}

terraform/modules/cloudwatch_logs/main.tf renamed to terraform/envs/prod/main.tf

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ terraform {
99
required_version = ">= 1.2"
1010
}
1111

12+
provider "aws" {
13+
region = "us-east-1"
14+
default_tags {
15+
tags = {
16+
project = var.ProjectId
17+
}
18+
}
19+
}
1220

1321
import {
1422
to = aws_cloudwatch_log_group.main_app_logs
15-
id = "${var.resource_prefix}-logs"
23+
id = "/aws/lambda/${var.ProjectId}-lambda"
1624
}
17-
18-
1925
resource "aws_cloudwatch_log_group" "main_app_logs" {
20-
name = "${var.resource_prefix}-logs"
21-
retention_in_days = var.retention_in_days
26+
name = "/aws/lambda/${var.ProjectId}-lambda"
27+
retention_in_days = var.LogRetentionDays
2228
}

terraform/envs/prod/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "LogRetentionDays" {
2+
type = number
3+
default = 90
4+
}
5+
6+
variable "ProjectId" {
7+
type = string
8+
default = "infra-core-api"
9+
}
10+

terraform/envs/qa/.terraform.lock.hcl

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

terraform/envs/qa/main.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ terraform {
1111

1212
provider "aws" {
1313
region = "us-east-1"
14+
default_tags {
15+
tags = {
16+
project = var.ProjectId
17+
}
18+
}
1419
}
1520

16-
module "cloudwatch_logs" {
17-
source = "../../modules/cloudwatch_logs"
18-
resource_prefix = var.ResourcePrefix
21+
import {
22+
to = aws_cloudwatch_log_group.main_app_logs
23+
id = "/aws/lambda/${var.ProjectId}-lambda"
24+
}
25+
resource "aws_cloudwatch_log_group" "main_app_logs" {
26+
name = "/aws/lambda/${var.ProjectId}-lambda"
1927
retention_in_days = var.LogRetentionDays
2028
}

terraform/envs/qa/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ variable "LogRetentionDays" {
33
default = 7
44
}
55

6-
variable "ResourcePrefix" {
6+
variable "ProjectId" {
77
type = string
88
default = "infra-core-api"
99
}

terraform/modules/cloudwatch_logs/variables.tf

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

0 commit comments

Comments
 (0)