Page MenuHomePhabricator

D5345.diff
No OneTemporary

D5345.diff

diff --git a/services/terraform/localstack.tf b/services/terraform/localstack.tf
deleted file mode 100644
--- a/services/terraform/localstack.tf
+++ /dev/null
@@ -1,20 +0,0 @@
-variable "HOST" {
- type = string
- default = "http://localhost:4566"
-}
-
-// https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/custom-service-endpoints#localstack
-provider "aws" {
- region = "us-east-2"
- access_key = "fake"
- secret_key = "fake"
- skip_credentials_validation = true
- skip_metadata_api_check = true
- skip_requesting_account_id = true
- s3_use_path_style = true
-
- endpoints {
- dynamodb = var.HOST
- s3 = var.HOST
- }
-}
diff --git a/services/terraform/main.tf b/services/terraform/main.tf
new file mode 100644
--- /dev/null
+++ b/services/terraform/main.tf
@@ -0,0 +1,51 @@
+locals {
+ use_localstack = (terraform.workspace == "default")
+
+ aws_settings = (
+ local.use_localstack ?
+ {
+ region = "us-east-2"
+ access_key = "fake"
+ secret_key = "fake"
+
+ skip_credentials_validation = true
+ skip_metadata_api_check = true
+ skip_requesting_account_id = true
+ s3_use_path_style = true
+
+ override_endpoint = "http://localhost:4566"
+ } :
+ {
+ region = null
+ access_key = null
+ secret_key = null
+
+ skip_credentials_validation = null
+ skip_metadata_api_check = null
+ skip_requesting_account_id = null
+ s3_use_path_style = null
+
+ override_endpoint = null
+ }
+ )
+}
+
+provider "aws" {
+ region = local.aws_settings.region
+ access_key = local.aws_settings.access_key
+ secret_key = local.aws_settings.secret_key
+
+ skip_credentials_validation = local.aws_settings.skip_credentials_validation
+ skip_metadata_api_check = local.aws_settings.skip_metadata_api_check
+ skip_requesting_account_id = local.aws_settings.skip_requesting_account_id
+ s3_use_path_style = local.aws_settings.s3_use_path_style
+
+
+ dynamic "endpoints" {
+ for_each = local.aws_settings.override_endpoint[*]
+ content {
+ dynamodb = endpoints.value
+ s3 = endpoints.value
+ }
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 7:20 PM (17 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2682576
Default Alt Text
D5345.diff (2 KB)

Event Timeline