Skip to content

Commit

Permalink
Adding region to the terraform configs
Browse files Browse the repository at this point in the history
Using locals seems to cause issue at destroy time. I have moved the logic to extract the aws region from Confluent cluster bootstrap URL in the start.sh . This way it is showing up as an autogenerated variable in the configs.auto.tfvars
  • Loading branch information
gianlucanatali committed Jul 28, 2021
1 parent bf68f9f commit c194245
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions streaming-pacman/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export TOPICS_TO_CREATE="USER_GAME USER_LOSSES"


function create_tfvars_file {

AWS_REGION=$(echo "$BOOTSTRAP_SERVERS" | awk -F'.' '{print $2}')

TFVAR_S3_BUCKET=""
if [ -z ${S3_BUCKET_NAME+x} ];
then
Expand All @@ -35,6 +38,7 @@ ksql_endpoint="$KSQLDB_ENDPOINT"
ksql_basic_auth_user_info="$KSQLDB_BASIC_AUTH_USER_INFO"
aws_access_key="$AWS_ACCESS_KEY"
aws_secret_key="$AWS_SECRET_KEY"
aws_region="$AWS_REGION"
$TFVAR_S3_BUCKET
EOF
Expand Down
11 changes: 6 additions & 5 deletions streaming-pacman/terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
provider "aws" {
access_key = var.aws_access_key
secret_key = var.aws_secret_key
region = local.region
region = var.aws_region

}

data "aws_availability_zones" "available" {
Expand Down Expand Up @@ -76,6 +77,10 @@ variable "aws_secret_key" {
type = string
}

variable "aws_region" {
type = string
}

###########################################
############ CCloud Variables #############
###########################################
Expand All @@ -92,10 +97,6 @@ variable "cluster_api_secret" {
type = string
}

locals {
region = split(".", var.bootstrap_server)[1]
}

variable "scoreboard_topic" {
type = string
default = "SCOREBOARD"
Expand Down

0 comments on commit c194245

Please sign in to comment.