Skip to content

Commit 07cd46e

Browse files
authored
Merge pull request #44 from hackforla/17-restucture-backend-tfvars-local
Issue 17 - Restructure backlend for local tfvars file
2 parents 4c2eb03 + 3ac7be3 commit 07cd46e

File tree

7 files changed

+47
-11
lines changed

7 files changed

+47
-11
lines changed

.github/workflows/terraform-apply.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ jobs:
3232
uses: dflook/terraform-apply@v1
3333
with:
3434
path: terraform
35+
backend_config_file: terraform/prod.backend.tfvars

.github/workflows/terraform-plan.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ jobs:
3232
uses: dflook/terraform-plan@v1
3333
with:
3434
path: terraform
35+
backend_config_file: terraform/prod.backend.tfvars

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Ignore variables files
55
*.auto.tfvars
66

7+
# Ignore local development variable file
8+
backend.tfvars
9+
710
# Ignore override files
811
*.tfoverride
912

CONTRIBUTING.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Below are guidelines for contributing to the devops-security repository hosted o
2424
- [**Generating Access Keys for AWS CLI**](#generating-access-keys-for-aws-cli)
2525
- [**Installing Terraform**](#installing-terraform)
2626
- [**Creating Backend State**](#creating-backend-state)
27+
- [**Creating Local tfvars file**](#creating-local-tfvars-file)
2728
- [**Installing Terraform docs**](#installing-terraform-docs)
2829
- [**Clone (Create) a copy on your computer**](#clone-create-a-copy-on-your-computer)
2930
- [**Create a new branch where you will work on your issue**](#create-a-new-branch-where-you-will-work-on-your-issue)
@@ -153,6 +154,23 @@ To facilitate AWS IAM changes using Terraform, it's essential to establish backe
153154
<sub>[Back to Table of Contents](#table-of-contents)</sub>
154155
***
155156

157+
### **Creating Local tfvars file**
158+
159+
Atfer creating a backend state, create a ```backend.tfvars``` file in the ```terraform``` directory. It should have content of this format:
160+
161+
```
162+
bucket = "{developer_specific}-hfla-ops-terraform-state"
163+
key = "devops-security/terraform.tfstate"
164+
region = "us-east-2"
165+
dynamodb_table = "{developer_specific}_hfla_ops_terraform_table"
166+
encrypt = true
167+
```
168+
169+
Remeber to match these values to the ones in your backend state (and replace {developer-specific} with your actual name)
170+
171+
<sub>[Back to Table of Contents](#table-of-contents)</sub>
172+
***
173+
156174
### **Installing Terraform docs**
157175

158176
Follow the Terraform docs [installation guide](https://terraform-docs.io/user-guide/installation/)
@@ -224,7 +242,7 @@ cd terraform
224242
- Next initilize the terraform configuration
225243
226244
```bash
227-
terraform init
245+
terraform init --backend-config=backend.tfvars
228246
```
229247
230248
- Then generate and run an execution plan

terraform/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,23 @@ Resources created by this code repository.
77

88
| Name | Source | Version |
99
|------|--------|---------|
10+
| <a name="module_aws_custom_policies"></a> [aws\_custom\_policies](#module\_aws\_custom\_policies) | ./modules/aws-policies | n/a |
11+
| <a name="module_iam_oidc_gha_incubator"></a> [iam\_oidc\_gha\_incubator](#module\_iam\_oidc\_gha\_incubator) | ./modules/aws-gha-oidc-providers | n/a |
1012
| <a name="module_iam_read_only_group"></a> [iam\_read\_only\_group](#module\_iam\_read\_only\_group) | ./modules/aws-groups | n/a |
11-
| <a name="module_iam_user_gwenstacy"></a> [iam\_user\_gwenstacy](#module\_iam\_user\_gwenstacy) | ./modules/aws-users | n/a |
13+
| <a name="module_iam_services_supervisor_group"></a> [iam\_services\_supervisor\_group](#module\_iam\_services\_supervisor\_group) | ./modules/aws-groups | n/a |
14+
| <a name="module_iam_user_JimmyJuarez10"></a> [iam\_user\_JimmyJuarez10](#module\_iam\_user\_JimmyJuarez10) | ./modules/aws-users | n/a |
15+
| <a name="module_iam_user_abbyz123"></a> [iam\_user\_abbyz123](#module\_iam\_user\_abbyz123) | ./modules/aws-users | n/a |
16+
| <a name="module_iam_user_awlFCCamp"></a> [iam\_user\_awlFCCamp](#module\_iam\_user\_awlFCCamp) | ./modules/aws-users | n/a |
17+
| <a name="module_iam_user_brittanyms"></a> [iam\_user\_brittanyms](#module\_iam\_user\_brittanyms) | ./modules/aws-users | n/a |
18+
| <a name="module_iam_user_chelseyb"></a> [iam\_user\_chelseyb](#module\_iam\_user\_chelseyb) | ./modules/aws-users | n/a |
19+
| <a name="module_iam_user_freaky4wrld"></a> [iam\_user\_freaky4wrld](#module\_iam\_user\_freaky4wrld) | ./modules/aws-users | n/a |
20+
| <a name="module_iam_user_jbubar"></a> [iam\_user\_jbubar](#module\_iam\_user\_jbubar) | ./modules/aws-users | n/a |
21+
| <a name="module_iam_user_samuelusc"></a> [iam\_user\_samuelusc](#module\_iam\_user\_samuelusc) | ./modules/aws-users | n/a |
22+
| <a name="module_iam_user_shikha0428"></a> [iam\_user\_shikha0428](#module\_iam\_user\_shikha0428) | ./modules/aws-users | n/a |
23+
| <a name="module_iam_user_shinjonathan"></a> [iam\_user\_shinjonathan](#module\_iam\_user\_shinjonathan) | ./modules/aws-users | n/a |
24+
| <a name="module_iam_user_spiteless"></a> [iam\_user\_spiteless](#module\_iam\_user\_spiteless) | ./modules/aws-users | n/a |
25+
| <a name="module_iam_user_testiamuser"></a> [iam\_user\_testiamuser](#module\_iam\_user\_testiamuser) | ./modules/aws-users | n/a |
26+
| <a name="module_iam_user_tylerthome"></a> [iam\_user\_tylerthome](#module\_iam\_user\_tylerthome) | ./modules/aws-users | n/a |
1227

1328

1429

@@ -30,6 +45,4 @@ Terraform directory structure
3045
To automatically update this documentation, install terraform-docs on your local machine run the following:
3146
`cd <directory of README location to update>`
3247
`terraform-docs -c .terraform.docs.yml .`
33-
<!-- END_TF_DOCS -->
34-
35-
Much of this content was generated using ChatGPT-4; reviewed and edited by humans
48+
<!-- END_TF_DOCS -->

terraform/backend.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
terraform {
22
backend "s3" {
3-
bucket = "hfla-ops-terraform-state"
4-
key = "devops-security/terraform.tfstate"
5-
region = "us-west-2"
6-
dynamodb_table = "hfla_ops_terraform_table"
7-
encrypt = true
83
}
9-
}
4+
}

terraform/prod.backend.tfvars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bucket = "hfla-ops-terraform-state"
2+
key = "devops-security/terraform.tfstate"
3+
region = "us-west-2"
4+
dynamodb_table = "hfla_ops_terraform_table"
5+
encrypt = true

0 commit comments

Comments
 (0)