def pretf_blocks(var): # Create variables needed by this file. yield variable.account(type="string") yield variable.aws_credentials( default={ "nonprod": {"profile": "pretf-nonprod"}, "prod": {"profile": "pretf-prod"}, } ) yield variable.aws_region(default="eu-west-1") yield variable.environment(type="string") yield variable.stack(type="string") # Create a backend configuration using the environment details. # Stacks in the same account share backend resources. yield terraform_backend_s3( bucket=f"pretf-example-project-{var.account}", dynamodb_table=f"pretf-example-project-{var.account}", key=f"{var.stack}/{var.environment}/terraform.tfstate", region=var.aws_region, **var.aws_credentials[var.account], ) # Create a default AWS provider for this environment. yield provider_aws( region=var.aws_region, **var.aws_credentials[var.account], )
def pretf_blocks(): yield terraform_backend_s3( bucket="terraform-aws-lambda-builder", dynamodb_table="terraform-aws-lambda-builder", key="nodejs/terraform.tfstate", profile="rbutcher", region="eu-west-1", )
def pretf_blocks(var): yield terraform_backend_s3( bucket="pretf-examples-aws", dynamodb_table="pretf-examples-aws", key="terraform.tfstate", region=var.aws_region, **var.aws_credentials["nonprod"], )
def pretf_blocks(): yield terraform_backend_s3( bucket="terraform-aws-fargate-service", dynamodb_table="terraform-aws-fargate-service", key="terraform.tfstate", profile="claranetuk-thirdplaygroundRW", region="eu-west-1", )
def pretf_blocks(var): # Create variables needed by this file. yield block( "variable", "aws_credentials", { "default": { "nonprod": { "profile": "pretf-nonprod", }, "prod": { "profile": "pretf-prod", }, }, }) yield block("variable", "aws_region", { "default": "eu-west-1", }) yield block("variable", "environment", { "type": "string", }) yield block("variable", "stack", { "type": "string", }) # Create a backend configuration using the environment details. # Stacks in the same account share backend resources. if var.environment == 'prod': account = "prod" else: account = "nonprod" backend = f"pretf-examples-flatten-{account}" yield terraform_backend_s3( bucket=backend, dynamodb_table=backend, key=f"{var.stack}/terraform.tfstate", region=var.aws_region, **var.aws_credentials[account], ) # Create a default AWS provider for this environment. yield provider_aws( region=var.aws_region, **var.aws_credentials[account], )
def pretf_blocks(terraform, var): # Create variables needed by this file. yield block( "variable", "aws_credentials", { "default": { "nonprod": { "profile": "pretf-nonprod", }, "prod": { "profile": "pretf-prod", }, }, }) yield block("variable", "aws_region", { "default": "eu-west-1", }) yield block("variable", "environment", { "type": "string", }) yield block("variable", "stack", { "type": "string", }) # Create a backend configuration in the prod account, # because all workspaces must use the same backend. yield terraform_backend_s3( bucket="pretf-examples-workspaces", dynamodb_table="pretf-examples-workspaces", key=f"{var.stack}/terraform.tfstate", region="eu-west-1", workspace_key_prefix="", **var.aws_credentials["prod"], ) # Create a default AWS provider for this workspace. if terraform.workspace == "prod": account = "prod" else: account = "nonprod" yield provider_aws( region=var.aws_region, **var.aws_credentials[account], )