-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add record of state storage resource addition
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Created bucket and table manually: | ||
|
||
``` | ||
aws s3api create-bucket --bucket osm-terraform-storage --region us-east-1 | ||
aws s3api list-buckets | ||
aws s3api list-buckets --region us-east-1 | ||
aws s3api put-bucket-versioning --bucket osm-terraform-storage --versioning-configuration Status=Enabled | ||
aws s3 cp state-storage.tf s3://osm-terraform-storage/test.tf | ||
aws s3 rm s3://osm-terraform-storage --recursive | ||
# Failed: aws dynamodb create-table --table-name terraform-locks --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --billing-mode PAY_PER_REQUEST --region us-east-1 | ||
# Created dynamodb-policy.json | ||
aws iam create-policy --policy-name DynamoDBFullAccess --policy-document file://dynamodb-policy.json | ||
aws iam attach-user-policy --policy-arn arn:aws:iam::507624629289:policy/DynamoDBFullAccess --user-name osm | ||
aws iam list-attached-user-policies --user-name osm | ||
aws dynamodb create-table --table-name terraform-locks --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --billing-mode PAY_PER_REQUEST --region us-east-1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"dynamodb:CreateTable", | ||
"dynamodb:DeleteTable", | ||
"dynamodb:DescribeTable", | ||
"dynamodb:ListTables", | ||
"dynamodb:UpdateTable", | ||
"dynamodb:PutItem", | ||
"dynamodb:GetItem", | ||
"dynamodb:DeleteItem", | ||
"dynamodb:Query", | ||
"dynamodb:Scan" | ||
], | ||
"Resource": "arn:aws:dynamodb:us-east-1:507624629289:table/terraform-locks" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"dynamodb:ListTables", | ||
"dynamodb:ListTagsOfResource" | ||
], | ||
"Resource": "*" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_s3_bucket" "tf_state" { | ||
bucket = "osm-storage" | ||
versioning { | ||
enabled = true | ||
} | ||
server_side_encryption_configuration { | ||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
} | ||
} | ||
lifecycle_rule { | ||
id = "tf_state" | ||
enabled = true | ||
transition { | ||
days = 30 | ||
storage_class = "STANDARD_IA" | ||
} | ||
expiration { | ||
days = 365 | ||
} | ||
} | ||
tags = { | ||
Name = "terraform-state-storage" | ||
} | ||
} | ||
|
||
resource "aws_dynamodb_table" "tf_locks" { | ||
name = "terraform-locks" | ||
billing_mode = "PAY_PER_REQUEST" | ||
hash_key = "LockID" | ||
|
||
attribute { | ||
name = "LockID" | ||
type = "S" | ||
} | ||
|
||
tags = { | ||
Name = "terraform-state-locks" | ||
} | ||
} |