Page MenuHomePhabricator

D8570.id28846.diff
No OneTemporary

D8570.id28846.diff

diff --git a/services/terraform/dev/main.tf b/services/terraform/dev/main.tf
--- a/services/terraform/dev/main.tf
+++ b/services/terraform/dev/main.tf
@@ -35,5 +35,6 @@
# Shared resources between local dev environment and remote AWS
module "shared" {
source = "../modules/shared"
+ is_dev = true
}
diff --git a/services/terraform/modules/shared/dynamodb.tf b/services/terraform/modules/shared/dynamodb.tf
--- a/services/terraform/modules/shared/dynamodb.tf
+++ b/services/terraform/modules/shared/dynamodb.tf
@@ -2,8 +2,8 @@
name = "backup-service-backup"
hash_key = "userID"
range_key = "backupID"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
attribute {
name = "userID"
@@ -24,8 +24,8 @@
name = "userID-created-index"
hash_key = "userID"
range_key = "created"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
projection_type = "INCLUDE"
non_key_attributes = ["recoveryData"]
}
@@ -35,8 +35,8 @@
name = "backup-service-log"
hash_key = "backupID"
range_key = "logID"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
attribute {
name = "backupID"
@@ -52,8 +52,8 @@
resource "aws_dynamodb_table" "blob-service-blob" {
name = "blob-service-blob"
hash_key = "blobHash"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
attribute {
name = "blobHash"
@@ -64,8 +64,8 @@
resource "aws_dynamodb_table" "blob-service-reverse-index" {
name = "blob-service-reverse-index"
hash_key = "holder"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
attribute {
name = "holder"
@@ -80,13 +80,16 @@
global_secondary_index {
name = "blobHash-index"
hash_key = "blobHash"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
projection_type = "ALL"
}
}
resource "aws_dynamodb_table" "tunnelbroker-undelivered-messages" {
+ # This table doesnt exist in prod
+ count = var.is_dev ? 1 : 0
+
name = "tunnelbroker-undelivered-messages"
hash_key = "deviceID"
range_key = "createdAt"
@@ -107,8 +110,8 @@
resource "aws_dynamodb_table" "identity-users" {
name = "identity-users"
hash_key = "userID"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
attribute {
name = "userID"
@@ -120,30 +123,43 @@
type = "S"
}
- attribute {
- name = "walletAddress"
- type = "S"
+ # walletAddress not defined in prod
+ dynamic "attribute" {
+ # Create a dummy list to iterate over if is_dev is true
+ for_each = var.is_dev ? [1] : []
+ content {
+ name = "walletAddress"
+ type = "S"
+ }
}
global_secondary_index {
name = "username-index"
hash_key = "username"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = var.is_dev ? 10 : 1
+ read_capacity = var.is_dev ? 10 : 1
projection_type = "KEYS_ONLY"
}
- global_secondary_index {
- name = "walletAddress-index"
- hash_key = "walletAddress"
- write_capacity = 10
- read_capacity = 10
- projection_type = "KEYS_ONLY"
+ # walletAddress not defined in prod
+ dynamic "global_secondary_index" {
+ # Create a dummy list to iterate over if is_dev is true
+ for_each = var.is_dev ? [1] : []
+ content {
+ name = "walletAddress-index"
+ hash_key = "walletAddress"
+ write_capacity = 10
+ read_capacity = 10
+ projection_type = "KEYS_ONLY"
+ }
}
}
# Identity users with opaque_ke 2.0 credentials
resource "aws_dynamodb_table" "identity-users-opaque2" {
+ # This table doesnt exist in prod
+ count = var.is_dev ? 1 : 0
+
name = "identity-users-opaque2"
hash_key = "userID"
write_capacity = 10
@@ -185,8 +201,8 @@
name = "identity-tokens"
hash_key = "userID"
range_key = "signingPublicKey"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = 1
+ read_capacity = 1
attribute {
name = "userID"
@@ -200,6 +216,9 @@
}
resource "aws_dynamodb_table" "identity-nonces" {
+ # This table doesnt exist in prod
+ count = var.is_dev ? 1 : 0
+
name = "identity-nonces"
hash_key = "nonce"
write_capacity = 10
@@ -214,8 +233,8 @@
resource "aws_dynamodb_table" "identity-reserved-usernames" {
name = "identity-reserved-usernames"
hash_key = "username"
- write_capacity = 10
- read_capacity = 10
+ write_capacity = 1
+ read_capacity = 1
attribute {
name = "username"
diff --git a/services/terraform/modules/shared/variables.tf b/services/terraform/modules/shared/variables.tf
new file mode 100644
--- /dev/null
+++ b/services/terraform/modules/shared/variables.tf
@@ -0,0 +1,4 @@
+variable "is_dev" {
+ type = bool
+ default = false
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 6:58 AM (20 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2449909
Default Alt Text
D8570.id28846.diff (5 KB)

Event Timeline