Skip to content

Commit e473850

Browse files
authored
[refactor] rm unneeded vars (#281)
We have had support in tftest for awhile to generate our standard vars. Make use of that everywhere.
1 parent 9be9388 commit e473850

File tree

39 files changed

+138
-360
lines changed

39 files changed

+138
-360
lines changed

.github/workflows/ci.yml

+47-45
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,8 @@ jobs:
2626
test:
2727
name: test ${{ matrix.module }}
2828
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v2
31-
- id: filter
32-
uses: dorny/paths-filter@v2
33-
with:
34-
filters: |
35-
module:
36-
- '${{ matrix.module }}/**'
37-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
38-
uses: hashicorp/setup-terraform@v1
39-
with:
40-
terraform_version: 0.12.30
41-
terraform_wrapper: "false"
42-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
43-
uses: actions/setup-go@v2
44-
with:
45-
go-version: 1.14.3
46-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
47-
name: Install bless provider
48-
run: curl -s https://raw.githubusercontent.com/chanzuckerberg/terraform-provider-bless/main/download.sh | bash -s -- -b $HOME/.terraform.d/plugins/ -d
49-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
50-
name: Check bless provider
51-
run: ls -al $HOME/.terraform.d/plugins/terraform-provider-bless*
52-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
53-
name: Install Snowflake provider
54-
run: curl -s https://raw.githubusercontent.com/chanzuckerberg/terraform-provider-snowflake/main/download.sh | bash -s -- -b $HOME/.terraform.d/plugins/ -d
55-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
56-
name: Check Snowflake provider
57-
run: ls -al $HOME/.terraform.d/plugins/terraform-provider-snowflake*
58-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
59-
run: aws configure set aws_access_key_id ${{ secrets.CI1_AWS_ACCESS_KEY_ID }} --profile cztack-ci-1
60-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
61-
run: aws configure set aws_secret_access_key ${{ secrets.CI1_AWS_SECRET_ACCESS_KEY }} --profile cztack-ci-1
62-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
63-
run: aws --profile cztack-ci-1 sts get-caller-identity
64-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
65-
run: aws configure set aws_access_key_id ${{ secrets.CI2_AWS_ACCESS_KEY_ID }} --profile cztack-ci-2
66-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
67-
run: aws configure set aws_secret_access_key ${{ secrets.CI2_AWS_SECRET_ACCESS_KEY }} --profile cztack-ci-2
68-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
69-
run: aws --profile cztack-ci-2 sts get-caller-identity
70-
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
71-
run: make test-ci TEST=./${{ matrix.module }}
7229
strategy:
30+
fail-fast: false
7331
matrix:
7432
module:
7533
- aws-acm-cert
@@ -118,7 +76,7 @@ jobs:
11876
- aws-sns-lambda
11977
- aws-ssm-params
12078
- aws-ssm-params-writer
121-
- bless-ca/test
79+
# - bless-ca/test
12280
- github-webhooks-to-s3
12381
- module-template
12482
- snowflake-account-grant-all
@@ -137,10 +95,54 @@ jobs:
13795
- snowflake-table-grant-all
13896
- snowflake-view-grant-all
13997
- snowflake-warehouse-grant-all
98+
steps:
99+
- uses: actions/checkout@v2
100+
- id: filter
101+
uses: dorny/paths-filter@v2
102+
with:
103+
filters: |
104+
module:
105+
- '${{ matrix.module }}/**'
106+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
107+
uses: hashicorp/setup-terraform@v1
108+
with:
109+
terraform_version: 0.12.30
110+
terraform_wrapper: "false"
111+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
112+
uses: actions/setup-go@v2
113+
with:
114+
go-version: 1.14.3
115+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
116+
name: Install bless provider
117+
run: curl -s https://raw.githubusercontent.com/chanzuckerberg/terraform-provider-bless/main/download.sh | bash -s -- -b $HOME/.terraform.d/plugins/ -d
118+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
119+
name: Check bless provider
120+
run: ls -al $HOME/.terraform.d/plugins/terraform-provider-bless*
121+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
122+
name: Install Snowflake provider
123+
run: curl -s https://raw.githubusercontent.com/chanzuckerberg/terraform-provider-snowflake/main/download.sh | bash -s -- -b $HOME/.terraform.d/plugins/ -d
124+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
125+
name: Check Snowflake provider
126+
run: ls -al $HOME/.terraform.d/plugins/terraform-provider-snowflake*
127+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
128+
run: aws configure set aws_access_key_id ${{ secrets.CI1_AWS_ACCESS_KEY_ID }} --profile cztack-ci-1
129+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
130+
run: aws configure set aws_secret_access_key ${{ secrets.CI1_AWS_SECRET_ACCESS_KEY }} --profile cztack-ci-1
131+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
132+
run: aws --profile cztack-ci-1 sts get-caller-identity
133+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
134+
run: aws configure set aws_access_key_id ${{ secrets.CI2_AWS_ACCESS_KEY_ID }} --profile cztack-ci-2
135+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
136+
run: aws configure set aws_secret_access_key ${{ secrets.CI2_AWS_SECRET_ACCESS_KEY }} --profile cztack-ci-2
137+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
138+
run: aws --profile cztack-ci-2 sts get-caller-identity
139+
- if: github.event == 'push' || steps.filter.outputs.module == 'true'
140+
run: make test-ci TEST=./${{ matrix.module }}
141+
140142
timeout-minutes: 45
141143
name: CI
142144
"on":
143-
pull_request: null
145+
pull_request:
144146
push:
145147
branches:
146148
- main

aws-acm-cert/module_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ func TestAWSACMCertDefaults(t *testing.T) {
2020

2121
test := tftest.Test{
2222
Setup: func(t *testing.T) *terraform.Options {
23-
project := tftest.UniqueID()
24-
env := tftest.UniqueID()
25-
service := tftest.UniqueID()
26-
owner := tftest.UniqueID()
27-
2823
certDomainName := fmt.Sprintf(
2924
"%s.%s",
3025
tftest.UniqueID(),
@@ -44,11 +39,6 @@ func TestAWSACMCertDefaults(t *testing.T) {
4439
return tftest.Options(
4540
tftest.DefaultRegion,
4641
map[string]interface{}{
47-
"project": project,
48-
"env": env,
49-
"service": service,
50-
"owner": owner,
51-
5242
"cert_domain_name": certDomainName,
5343
"aws_route53_zone_id": route53ZoneID,
5444
"validation_record_ttl": 5,

aws-aurora-mysql/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ func TestAWSAuroraMysqlDefaults(t *testing.T) {
1313
test := tftest.Test{
1414

1515
Setup: func(t *testing.T) *terraform.Options {
16-
project := tftest.UniqueID()
17-
env := tftest.UniqueID()
18-
service := tftest.UniqueID()
19-
owner := tftest.UniqueID()
20-
2116
vpc := tftest.EnvVar(tftest.EnvVPCID)
2217
databaseSubnetGroup := tftest.EnvVar(tftest.EnvDatabaseSubnetGroup)
2318
ingressCidrBlocks := tftest.EnvVar(tftest.EnvVPCCIDRBlock)
@@ -29,10 +24,6 @@ func TestAWSAuroraMysqlDefaults(t *testing.T) {
2924
return tftest.Options(
3025
tftest.DefaultRegion,
3126
map[string]interface{}{
32-
"project": project,
33-
"env": env,
34-
"service": service,
35-
"owner": owner,
3627

3728
"vpc_id": vpc,
3829
"database_subnet_group": databaseSubnetGroup,

aws-cloudfront-domain-redirect/module_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ func TestModule(t *testing.T) {
1616
route53Zone := tftest.EnvVar(tftest.EnvRoute53ZoneName)
1717
targetSubdomain := tftest.UniqueID()
1818

19-
project := tftest.UniqueID()
20-
env := tftest.UniqueID()
21-
service := tftest.UniqueID()
22-
owner := tftest.UniqueID()
23-
2419
target_domain := fmt.Sprintf("%s.%s", targetSubdomain, route53Zone)
2520
source_domain := fmt.Sprintf("%s.%s", tftest.UniqueID(), route53Zone)
2621
source_domain_zone_id := tftest.EnvVar(tftest.EnvRoute53ZoneID)
@@ -31,11 +26,6 @@ func TestModule(t *testing.T) {
3126
"target_domain": target_domain,
3227
"source_domain": source_domain,
3328
"source_domain_zone_id": source_domain_zone_id,
34-
35-
"project": project,
36-
"env": env,
37-
"service": service,
38-
"owner": owner,
3929
},
4030
)
4131
},

aws-cloudfront-logs-bucket/module_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,11 @@ import (
1313
func TestPrivateBucketDefaults(t *testing.T) {
1414
test := &tftest.Test{
1515
Setup: func(t *testing.T) *terraform.Options {
16-
project := tftest.UniqueID()
17-
env := tftest.UniqueID()
18-
service := tftest.UniqueID()
19-
owner := tftest.UniqueID()
20-
2116
bucketName := tftest.UniqueID()
2217

2318
return tftest.Options(
2419
tftest.DefaultRegion,
2520
map[string]interface{}{
26-
"project": project,
27-
"env": env,
28-
"service": service,
29-
"owner": owner,
30-
3121
"bucket_name": bucketName,
3222
},
3323
)

aws-efs-volume/module_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ import (
1010
func TestEfsVolume(t *testing.T) {
1111
test := tftest.Test{
1212
Setup: func(t *testing.T) *terraform.Options {
13-
project := tftest.UniqueID()
14-
env := tftest.UniqueID()
15-
service := tftest.UniqueID()
16-
owner := tftest.UniqueID()
17-
1813
volumeName := tftest.UniqueID()
1914

2015
return tftest.Options(
2116
tftest.DefaultRegion,
2217
map[string]interface{}{
23-
"project": project,
24-
"env": env,
25-
"service": service,
26-
"owner": owner,
27-
2818
"volume_name": volumeName,
2919
"vpc_id": tftest.EnvVar(tftest.EnvVPCID),
3020
"subnet_ids": tftest.ListEnvVar("PRIVATE_SUBNETS"),

aws-iam-role-bless/module_test.go

+4-18
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,16 @@ import (
1111
func TestIAMRoleBless(t *testing.T) {
1212
test := tftest.Test{
1313
Setup: func(t *testing.T) *terraform.Options {
14-
region := tftest.IAMRegion
1514
curAcct := tftest.AWSCurrentAccountID(t)
1615

17-
project := tftest.UniqueID()
18-
env := tftest.UniqueID()
19-
service := tftest.UniqueID()
20-
owner := tftest.UniqueID()
21-
22-
return &terraform.Options{
23-
TerraformDir: ".",
24-
25-
Vars: map[string]interface{}{
16+
return tftest.Options(
17+
tftest.IAMRegion,
18+
map[string]interface{}{
2619
"role_name": random.UniqueId(),
2720
"source_account_id": curAcct,
28-
"project": project,
29-
"env": env,
30-
"service": service,
31-
"owner": owner,
3221
"bless_lambda_arns": []string{"arn:aws:lambda:us-west-2:111111111111:function:test"},
3322
},
34-
EnvVars: map[string]string{
35-
"AWS_DEFAULT_REGION": region,
36-
},
37-
}
23+
)
3824
},
3925
Validate: func(t *testing.T, options *terraform.Options) {},
4026
}

aws-iam-role-cloudfront-poweruser/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,13 @@ func TestAWSIAMRoleCloudfrontPoweruser(t *testing.T) {
1414
Setup: func(t *testing.T) *terraform.Options {
1515
curAcct := tftest.AWSCurrentAccountID(t)
1616

17-
project := tftest.UniqueID()
18-
env := tftest.UniqueID()
19-
service := tftest.UniqueID()
20-
owner := tftest.UniqueID()
21-
2217
return tftest.Options(
2318
tftest.IAMRegion,
2419

2520
map[string]interface{}{
2621
"role_name": random.UniqueId(),
2722
"iam_path": fmt.Sprintf("/%s/", random.UniqueId()),
2823
"source_account_id": curAcct,
29-
"project": project,
30-
"env": env,
31-
"service": service,
32-
"owner": owner,
3324
},
3425
)
3526
},

aws-iam-role-crossacct/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,12 @@ func TestAWSIAMRoleCrossAcct(t *testing.T) {
1313
Setup: func(t *testing.T) *terraform.Options {
1414
curAcct := tftest.AWSCurrentAccountID(t)
1515

16-
project := tftest.UniqueID()
17-
env := tftest.UniqueID()
18-
service := tftest.UniqueID()
19-
owner := tftest.UniqueID()
20-
2116
return tftest.Options(
2217
tftest.IAMRegion,
2318

2419
map[string]interface{}{
2520
"role_name": random.UniqueId(),
2621
"source_account_id": curAcct,
27-
"project": project,
28-
"env": env,
29-
"service": service,
30-
"owner": owner,
3122
},
3223
)
3324
},

aws-iam-role-ec2-poweruser/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@ func TestAWSIAMRoleEC2Poweruser(t *testing.T) {
1313
Setup: func(t *testing.T) *terraform.Options {
1414
curAcct := tftest.AWSCurrentAccountID(t)
1515

16-
project := tftest.UniqueID()
17-
env := tftest.UniqueID()
18-
service := tftest.UniqueID()
19-
owner := tftest.UniqueID()
20-
2116
return tftest.Options(
2217
tftest.IAMRegion,
2318
map[string]interface{}{
2419
"role_name": random.UniqueId(),
2520
"source_account_id": curAcct,
26-
"project": project,
27-
"env": env,
28-
"service": service,
29-
"owner": owner,
3021
},
3122
)
3223
},

aws-iam-role-ecs-poweruser/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ resource "aws_iam_role" "ecs-poweruser" {
5858

5959
resource "aws_iam_role_policy_attachment" "ecs-fullaccess" {
6060
role = aws_iam_role.ecs-poweruser.name
61-
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerServiceFullAccess"
61+
policy_arn = "arn:aws:iam::aws:policy/AmazonECS_FullAccess"
6262
}
6363

6464
resource "aws_iam_role_policy_attachment" "ecr-poweruser" {

aws-iam-role-ecs-poweruser/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,12 @@ func TestAWSIAMRoleEcsPoweruser(t *testing.T) {
1313
Setup: func(t *testing.T) *terraform.Options {
1414
curAcct := tftest.AWSCurrentAccountID(t)
1515

16-
project := tftest.UniqueID()
17-
env := tftest.UniqueID()
18-
service := tftest.UniqueID()
19-
owner := tftest.UniqueID()
20-
2116
return tftest.Options(
2217
tftest.IAMRegion,
2318

2419
map[string]interface{}{
2520
"role_name": random.UniqueId(),
2621
"source_account_id": curAcct,
27-
"project": project,
28-
"env": env,
29-
"service": service,
30-
"owner": owner,
3122
},
3223
)
3324
},

aws-iam-role-infraci/module_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,11 @@ func TestAWSIAMRoleInfraCI(t *testing.T) {
1414
Setup: func(t *testing.T) *terraform.Options {
1515
curAcct := tftest.AWSCurrentAccountID(t)
1616

17-
project := tftest.UniqueID()
18-
env := tftest.UniqueID()
19-
service := tftest.UniqueID()
20-
owner := tftest.UniqueID()
21-
2217
return tftest.Options(
2318
tftest.IAMRegion,
2419
map[string]interface{}{
2520
"role_name": random.UniqueId(),
2621
"source_account_id": curAcct,
27-
"project": project,
28-
"env": env,
29-
"service": service,
30-
"owner": owner,
3122
"iam_path": fmt.Sprintf("/%s/", random.UniqueId()),
3223
},
3324
)

0 commit comments

Comments
 (0)