Skip to content
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

restructure backend for local development #42

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 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: 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. 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
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
Loading