Skip to content

Commit

Permalink
Merge pull request #44 from hackforla/17-restucture-backend-tfvars-local
Browse files Browse the repository at this point in the history
Issue 17 - Restructure backlend for local tfvars file
  • Loading branch information
chelseybeck authored Aug 15, 2024
2 parents 4c2eb03 + 3ac7be3 commit 07cd46e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/terraform-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ jobs:
uses: dflook/terraform-apply@v1
with:
path: terraform
backend_config_file: terraform/prod.backend.tfvars
1 change: 1 addition & 0 deletions .github/workflows/terraform-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ jobs:
uses: dflook/terraform-plan@v1
with:
path: terraform
backend_config_file: terraform/prod.backend.tfvars
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Ignore variables files
*.auto.tfvars

# Ignore local development variable file
backend.tfvars

# Ignore override files
*.tfoverride

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

### **Creating Local tfvars file**

Atfer creating a backend state, create a ```backend.tfvars``` file in the ```terraform``` directory. It should have content of this format:

```
bucket = "{developer_specific}-hfla-ops-terraform-state"
key = "devops-security/terraform.tfstate"
region = "us-east-2"
dynamodb_table = "{developer_specific}_hfla_ops_terraform_table"
encrypt = true
```

Remeber to match these values to the ones in your backend state (and replace {developer-specific} with your actual name)

<sub>[Back to Table of Contents](#table-of-contents)</sub>
***

### **Installing Terraform docs**

Follow the Terraform docs [installation guide](https://terraform-docs.io/user-guide/installation/)
Expand Down Expand Up @@ -224,7 +242,7 @@ cd terraform
- Next initilize the terraform configuration
```bash
terraform init
terraform init --backend-config=backend.tfvars
```
- Then generate and run an execution plan
Expand Down
21 changes: 17 additions & 4 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,23 @@ Resources created by this code repository.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_aws_custom_policies"></a> [aws\_custom\_policies](#module\_aws\_custom\_policies) | ./modules/aws-policies | n/a |
| <a name="module_iam_oidc_gha_incubator"></a> [iam\_oidc\_gha\_incubator](#module\_iam\_oidc\_gha\_incubator) | ./modules/aws-gha-oidc-providers | n/a |
| <a name="module_iam_read_only_group"></a> [iam\_read\_only\_group](#module\_iam\_read\_only\_group) | ./modules/aws-groups | n/a |
| <a name="module_iam_user_gwenstacy"></a> [iam\_user\_gwenstacy](#module\_iam\_user\_gwenstacy) | ./modules/aws-users | n/a |
| <a name="module_iam_services_supervisor_group"></a> [iam\_services\_supervisor\_group](#module\_iam\_services\_supervisor\_group) | ./modules/aws-groups | n/a |
| <a name="module_iam_user_JimmyJuarez10"></a> [iam\_user\_JimmyJuarez10](#module\_iam\_user\_JimmyJuarez10) | ./modules/aws-users | n/a |
| <a name="module_iam_user_abbyz123"></a> [iam\_user\_abbyz123](#module\_iam\_user\_abbyz123) | ./modules/aws-users | n/a |
| <a name="module_iam_user_awlFCCamp"></a> [iam\_user\_awlFCCamp](#module\_iam\_user\_awlFCCamp) | ./modules/aws-users | n/a |
| <a name="module_iam_user_brittanyms"></a> [iam\_user\_brittanyms](#module\_iam\_user\_brittanyms) | ./modules/aws-users | n/a |
| <a name="module_iam_user_chelseyb"></a> [iam\_user\_chelseyb](#module\_iam\_user\_chelseyb) | ./modules/aws-users | n/a |
| <a name="module_iam_user_freaky4wrld"></a> [iam\_user\_freaky4wrld](#module\_iam\_user\_freaky4wrld) | ./modules/aws-users | n/a |
| <a name="module_iam_user_jbubar"></a> [iam\_user\_jbubar](#module\_iam\_user\_jbubar) | ./modules/aws-users | n/a |
| <a name="module_iam_user_samuelusc"></a> [iam\_user\_samuelusc](#module\_iam\_user\_samuelusc) | ./modules/aws-users | n/a |
| <a name="module_iam_user_shikha0428"></a> [iam\_user\_shikha0428](#module\_iam\_user\_shikha0428) | ./modules/aws-users | n/a |
| <a name="module_iam_user_shinjonathan"></a> [iam\_user\_shinjonathan](#module\_iam\_user\_shinjonathan) | ./modules/aws-users | n/a |
| <a name="module_iam_user_spiteless"></a> [iam\_user\_spiteless](#module\_iam\_user\_spiteless) | ./modules/aws-users | n/a |
| <a name="module_iam_user_testiamuser"></a> [iam\_user\_testiamuser](#module\_iam\_user\_testiamuser) | ./modules/aws-users | n/a |
| <a name="module_iam_user_tylerthome"></a> [iam\_user\_tylerthome](#module\_iam\_user\_tylerthome) | ./modules/aws-users | n/a |



Expand All @@ -30,6 +45,4 @@ Terraform directory structure
To automatically update this documentation, install terraform-docs on your local machine run the following:
`cd <directory of README location to update>`
`terraform-docs -c .terraform.docs.yml .`
<!-- END_TF_DOCS -->

Much of this content was generated using ChatGPT-4; reviewed and edited by humans
<!-- END_TF_DOCS -->
7 changes: 1 addition & 6 deletions terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
terraform {
backend "s3" {
bucket = "hfla-ops-terraform-state"
key = "devops-security/terraform.tfstate"
region = "us-west-2"
dynamodb_table = "hfla_ops_terraform_table"
encrypt = true
}
}
}
5 changes: 5 additions & 0 deletions terraform/prod.backend.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bucket = "hfla-ops-terraform-state"
key = "devops-security/terraform.tfstate"
region = "us-west-2"
dynamodb_table = "hfla_ops_terraform_table"
encrypt = true

0 comments on commit 07cd46e

Please sign in to comment.