NEW: setup remote state and lock

This commit is contained in:
xpk
2020-08-10 15:17:23 +08:00
parent be750e31a1
commit 826251c39c
2 changed files with 60 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
resource "random_integer" "suffix" {
min = 1000
max = 9999
}
resource "aws_s3_bucket" "state" {
bucket = "tfstate-sandbox-hkex-${random_integer.suffix.result}"
force_destroy = true
tags = var.default-tags
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_dynamodb_table" "statelock-sandbox-HKEX" {
name = "statelock-sandbox-HKEX-${random_integer.suffix.result}"
read_capacity = 20
write_capacity = 20
hash_key = "LockId"
attribute {
name = "LockId"
type = "S"
}
tags = var.default-tags
}
output "state_bucket" {
value = aws_s3_bucket.state.bucket
}
output "lock_db" {
value = aws_dynamodb_table.statelock-sandbox-HKEX.name
}
+15
View File
@@ -0,0 +1,15 @@
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "aws_region" {}
provider "aws" {
access_key = var.aws_access_key
secret_key = var.aws_secret_key
region = var.aws_region
version = ">= 2.28.1"
}
variable "default-tags" {}
variable "vpc-cidr" {
default = "172.16.0.0/16"
}