File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
examples/simple-terraform-1-11 Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ terraform {
2+ required_version = " >= 0.15"
3+
4+ required_providers {
5+ aws = {
6+ source = " hashicorp/aws"
7+ version = " >= 4.0.0"
8+ }
9+ }
10+ }
11+
12+ provider "aws" {
13+ region = var. region
14+ }
15+
16+ provider "aws" {
17+ alias = " replica"
18+ region = var. replica_region
19+ }
20+
21+ module "remote_state" {
22+ source = " ../../"
23+
24+ # Do not create the DynamoDB lock table
25+ create_dynamodb_table = false
26+ # Instead, add S3 lock file permissions to the IAM policy
27+ terraform_iam_policy_add_lockfile_permissions = true
28+
29+ providers = {
30+ aws = aws
31+ aws.replica = aws.replica
32+ }
33+ }
34+
35+ resource "aws_iam_user" "terraform" {
36+ name = " TerraformUser"
37+ }
38+
39+ resource "aws_iam_user_policy_attachment" "remote_state_access" {
40+ user = aws_iam_user. terraform . name
41+ policy_arn = module. remote_state . terraform_iam_policy . arn
42+ }
Original file line number Diff line number Diff line change 1+ output "kms_key" {
2+ description = " The KMS customer master key to encrypt state buckets."
3+ value = module. remote_state . kms_key . key_id
4+ }
5+
6+ output "state_bucket" {
7+ description = " The S3 bucket to store the remote state file."
8+ value = module. remote_state . state_bucket . bucket
9+ }
Original file line number Diff line number Diff line change 1+ variable "region" {
2+ description = " The AWS region in which resources are set up."
3+ type = string
4+ default = " us-east-1"
5+ }
6+
7+ variable "replica_region" {
8+ description = " The AWS region to which the state bucket is replicated."
9+ type = string
10+ default = " us-west-1"
11+ }
You can’t perform that action at this time.
0 commit comments