Skip to content

Commit 438b343

Browse files
authored
Merge pull request #580 from bheesham/import-cis-to-terraform
Import CIS to Terraform; fixup incorrectly named indices in staging
2 parents 6e8cdf8 + 2d7f977 commit 438b343

File tree

15 files changed

+344
-0
lines changed

15 files changed

+344
-0
lines changed

terraform/infra/dev/dynamo.tf

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
resource "aws_dynamodb_table" "dynamo" {
2+
name = "${var.environment}-identity-vault"
3+
billing_mode = "PAY_PER_REQUEST"
4+
deletion_protection_enabled = false
5+
hash_key = "id"
6+
region = "us-west-2"
7+
stream_enabled = true
8+
stream_view_type = "KEYS_ONLY"
9+
table_class = "STANDARD"
10+
attribute {
11+
name = "id"
12+
type = "S"
13+
}
14+
attribute {
15+
name = "primary_email"
16+
type = "S"
17+
}
18+
attribute {
19+
name = "primary_username"
20+
type = "S"
21+
}
22+
attribute {
23+
name = "sequence_number"
24+
type = "S"
25+
}
26+
attribute {
27+
name = "user_uuid"
28+
type = "S"
29+
}
30+
global_secondary_index {
31+
hash_key = "primary_email"
32+
name = "${var.environment}-identity-vault-primary_email"
33+
non_key_attributes = []
34+
projection_type = "ALL"
35+
range_key = "id"
36+
}
37+
global_secondary_index {
38+
hash_key = "primary_username"
39+
name = "${var.environment}-identity-vault-primary_username"
40+
non_key_attributes = []
41+
projection_type = "ALL"
42+
range_key = "id"
43+
}
44+
global_secondary_index {
45+
hash_key = "sequence_number"
46+
name = "${var.environment}-identity-vault-sequence_number"
47+
non_key_attributes = []
48+
projection_type = "ALL"
49+
range_key = null
50+
}
51+
global_secondary_index {
52+
hash_key = "user_uuid"
53+
name = "${var.environment}-identity-vault-user_uuid"
54+
non_key_attributes = []
55+
projection_type = "ALL"
56+
range_key = "id"
57+
}
58+
point_in_time_recovery {
59+
enabled = false
60+
}
61+
ttl {
62+
enabled = false
63+
}
64+
tags = {
65+
application = "identity-vault"
66+
cis_environment = "development"
67+
}
68+
}

terraform/infra/dev/imports.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {
2+
id = "development-identity-vault"
3+
to = aws_dynamodb_table.dynamo
4+
}

terraform/infra/dev/provider.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ provider "aws" {
2626
Owner = "IAM"
2727
Repository = "github.com/mozilla-iam/cis"
2828
Environment = var.environment
29+
ManagedBy = "Terraform"
2930
}
3031
}
3132
}

terraform/infra/prod/.terraform.lock.hcl

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment = "production"

terraform/infra/prod/dynamo.tf

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
resource "aws_dynamodb_table" "dynamo" {
2+
billing_mode = "PAY_PER_REQUEST"
3+
deletion_protection_enabled = false
4+
hash_key = "id"
5+
name = "${var.environment}-identity-vault"
6+
region = "us-west-2"
7+
stream_enabled = true
8+
stream_view_type = "KEYS_ONLY"
9+
table_class = "STANDARD"
10+
attribute {
11+
name = "id"
12+
type = "S"
13+
}
14+
attribute {
15+
name = "primary_email"
16+
type = "S"
17+
}
18+
attribute {
19+
name = "primary_username"
20+
type = "S"
21+
}
22+
attribute {
23+
name = "sequence_number"
24+
type = "S"
25+
}
26+
attribute {
27+
name = "user_uuid"
28+
type = "S"
29+
}
30+
global_secondary_index {
31+
hash_key = "primary_email"
32+
name = "${var.environment}-identity-vault-primary_email"
33+
non_key_attributes = []
34+
projection_type = "ALL"
35+
range_key = "id"
36+
}
37+
global_secondary_index {
38+
hash_key = "primary_username"
39+
name = "${var.environment}-identity-vault-primary_username"
40+
non_key_attributes = []
41+
projection_type = "ALL"
42+
range_key = "id"
43+
}
44+
global_secondary_index {
45+
hash_key = "sequence_number"
46+
name = "${var.environment}-identity-vault-sequence_number"
47+
non_key_attributes = []
48+
projection_type = "ALL"
49+
}
50+
global_secondary_index {
51+
hash_key = "user_uuid"
52+
name = "${var.environment}-identity-vault-user_uuid"
53+
non_key_attributes = []
54+
projection_type = "ALL"
55+
range_key = "id"
56+
}
57+
point_in_time_recovery {
58+
enabled = true
59+
recovery_period_in_days = 35
60+
}
61+
ttl {
62+
enabled = false
63+
}
64+
tags = {
65+
application = "identity-vault"
66+
cis_environment = "production"
67+
}
68+
}

terraform/infra/prod/imports.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {
2+
id = "production-identity-vault"
3+
to = aws_dynamodb_table.dynamo
4+
}

terraform/infra/prod/provider.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Locked with:
2+
# terraform providers lock -platform darwin_amd64 -platform darwin_arm64 -platform linux_amd64 -platform linux_arm64
3+
terraform {
4+
required_version = ">= 1.5.0"
5+
backend "s3" {
6+
# Re-using the one from mozilla-iam/iam-infra, to save having multiple
7+
# places to audit.
8+
bucket = "eks-terraform-shared-state"
9+
key = "cis/terraform/infra/prod/terraform.tfstate"
10+
region = "us-west-2"
11+
}
12+
required_providers {
13+
aws = {
14+
source = "hashicorp/aws"
15+
version = "~> 6.0"
16+
}
17+
}
18+
}
19+
20+
provider "aws" {
21+
region = "us-west-2"
22+
default_tags {
23+
tags = {
24+
Component = "CIS"
25+
FunctionalArea = "SSO"
26+
Owner = "IAM"
27+
Repository = "github.com/mozilla-iam/cis"
28+
Environment = var.environment
29+
ManagedBy = "Terraform"
30+
}
31+
}
32+
}

terraform/infra/prod/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "environment" {
2+
type = string
3+
}

terraform/infra/test/.terraform.lock.hcl

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)