.gitignore | ||
.terraform-docs.yml | ||
.terraform-version | ||
.terraform.lock.hcl | ||
aws.data.tf | ||
aws.dynamodb.tf | ||
aws.iam.tf | ||
aws.kms.tf | ||
aws.s3.tf | ||
aws.ssm.tf | ||
LICENSE | ||
README.md | ||
README.terraform.md | ||
terraform.backend.remote.tfvars.sample | ||
terraform.meta.tf | ||
terraform.outputs.tf | ||
terraform.tfvars.sample | ||
terraform.variables.tf |
Terraform AWS Pre-base Infrastructure
Intro
This project deploys the basic resources necessary for running multi-user Terraform deployments on an AWS account.
- an s3 bucket for storing terraform states
- a dynamodb table for maintaining terraform locks
- an admin user intended for use in other IaC projects
- a kms key intended for securing other IaC project secrets
- a parameter store tree to keep outputs of this project for reference
This configuration is intended to be manually executed once at the beginning by the root user.
⚠️ | Re-deploying this project again after running other AWS IaC projects can be extremely destructive. |
---|
Usage
-
Install terraform. The required version is stated in
terraform.meta.tf
. You can also use tfenv to automatically get a suitable version. -
Insert backend config values in
terraform.backend.tfvars
. Seeterraform.backend.remote.tfvars.sample
for example, or configure your preferred backend. -
(optional) Login to terraform cloud to use the remote backend:
terraform login
-
Install terraform dependencies and initiate the backend:
terraform init -backend-config=terraform.backend.tfvars
-
Insert deployment-specific values in
terraform.tfvars
. Seeterraform.tfvars.sample
for example. -
Then execute as:
terraform apply -var-file=terraform.tfvars
Notes
-
⚠️ This project's state file should not be saved in the same AWS account where it is being deployed.
-
The terraform state is not saved in s3, because it is assumed that no s3 bucket for terraform states exists yet. Instead the terraform cloud remote backend is used. You may need to setup an account there. Or use local or your preferred backend. You should ensure security of the state file.
-
Generated outputs are also saved in a parameter store tree for future reference.