Skip to content

Instantly share code, notes, and snippets.

@mbround18
Created June 25, 2020 18:14
Show Gist options
  • Save mbround18/b7ff075e69373e70a5801d826decb88b to your computer and use it in GitHub Desktop.
Save mbround18/b7ff075e69373e70a5801d826decb88b to your computer and use it in GitHub Desktop.
Dynamic switch to localstack
provider "aws" {
region = var.aws_region
s3_force_path_style = var.use_localstack
skip_credentials_validation = var.use_localstack
skip_metadata_api_check = var.use_localstack
# Note: all services are now exposed via a single edge port: https://github.com/localstack/localstack
dynamic "endpoints" {
for_each = var.use_localstack ? [var.localstack_host] : []
content {
apigateway = endpoints.value
cloudformation = endpoints.value
cloudwatch = endpoints.value
dynamodb = endpoints.value
es = endpoints.value
firehose = endpoints.value
iam = endpoints.value
kinesis = endpoints.value
lambda = endpoints.value
route53 = endpoints.value
redshift = endpoints.value
s3 = endpoints.value
secretsmanager = endpoints.value
ses = endpoints.value
sns = endpoints.value
sqs = endpoints.value
ssm = endpoints.value
stepfunctions = endpoints.value
sts = endpoints.value
xray = endpoints.value
}
}
variable "aws_region" {
type = string
default = "us-east-1"
description = "Sets the region used in AWS"
}
variable "localstack_host" {
type = string
default = "http://localhost:4566"
description = "The host in which localstack is running on."
}
variable "use_localstack" {
type = bool
default = true
description = "Whether or not to use localstack. If false it will attempt to deploy live."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment