Terraform
Terraform
Terraform section
See pip Installation.
AWS profiles in terraform
Instead of hardcoding AWS credentials in terraform try this to reference locally stored credentials;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
provider "aws" {
region = "region"
shared_credentials_file = "$HOME/.aws/credentials # default
profile = "default" # you may change to desired profile
}
terraform {
backend "s3" {
profile = "default" # change to desired profile
# Replace this with your bucket name!
bucket = "great-name-terraform-state-2"
key = "global/s3/terraform.tfstate"
region = "eu-central-1"
# Replace this with your DynamoDB table name!
dynamodb_table = "great-name-locks-2"
encrypt = true
}
}
Notes: terraform error
1
2
3
4
5
6
7
8
9
10
11
Error: Provider configuration not present
To work with
module.main.module.lambdas.module.data-transformation-lambda.aws_s3_bucket.junk_bucket
(orphan) its original provider configuration at
module.main.module.lambdas.module.data-transformation-lambda.provider["registry.terraform.io/hashicorp/aws"]
is required, but it has been removed. This occurs when a provider
configuration is removed while objects created by that provider still exist in
the state. Re-add the provider configuration to destroy
module.main.module.lambdas.module.data-transformation-lambda.aws_s3_bucket.junk_bucket
(orphan), after which you can remove the provider configuration again.
Remove specific resource (this is NOT a recommended best practice), sometimes required as a get out of jail.
1
terraform destroy -target module.main.module.lambdas.module.data-transformation-lambda.aws_s3_bucket.junk_bucket
How to evolve terraform setup Testing Terraform How to test IaC TerraTest Gruntworks How to clean up TF state How to deploy multiple stack github actions