diff --git a/.github/workflows/aws_tf_appy.yml b/.github/workflows/aws_tf_appy.yml index 45ebcba..d64c304 100644 --- a/.github/workflows/aws_tf_appy.yml +++ b/.github/workflows/aws_tf_appy.yml @@ -66,4 +66,11 @@ jobs: run: exit 1 - name: Terraform Apply - run: terraform apply -auto-approve \ No newline at end of file + run: terraform apply -auto-approve + + - name: Capture Output in .txt file + run: terraform output > ${{ github.workspace }}/output.txt + + - name: Display Out put file + run: | + cat ${{ github.workspace }}/output.txt \ No newline at end of file diff --git a/AWS-Multi-Region-Deployment/SNS/main.tf b/AWS-Multi-Region-Deployment/SNS/main.tf index dd70ebc..0f3be8a 100644 --- a/AWS-Multi-Region-Deployment/SNS/main.tf +++ b/AWS-Multi-Region-Deployment/SNS/main.tf @@ -1,10 +1,10 @@ +/* resource "aws_sns_topic" "example" { - count = length(var.aws_regions) - name = "${var.aws_sns_topic_name}-${var.aws_regions[count.index]}" + name = "${var.aws_sns_topic_name}-${var.aws_region}" display_name = "Multi Region SNS Topic" - provider = aws.regions[var.aws_regions[count.index]] } output "sns_topic_arns" { value = aws_sns_topic.example.*.arn -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/AWS-Multi-Region-Deployment/SNS/variables.tf b/AWS-Multi-Region-Deployment/SNS/variables.tf index 49f7608..28f2d44 100644 --- a/AWS-Multi-Region-Deployment/SNS/variables.tf +++ b/AWS-Multi-Region-Deployment/SNS/variables.tf @@ -1,9 +1,8 @@ -variable "aws_regions" { - type = list(string) - default = ["us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1"] -} - variable "aws_sns_topic_name" { type = string default = "cloud_quick_labs_sns" +} + +variable "aws_region" { + type = string } \ No newline at end of file diff --git a/AWS-Multi-Region-Deployment/main.tf b/AWS-Multi-Region-Deployment/main.tf index cb8fcdb..b56b41b 100644 --- a/AWS-Multi-Region-Deployment/main.tf +++ b/AWS-Multi-Region-Deployment/main.tf @@ -1,7 +1,37 @@ -provider "aws" { - region = var.aws_region +module "us-east-1" { + source = "./SNS" + + aws_region = "us-east-1" + aws_sns_topic_name = var.aws_sns_topic_name +} + +module "us-east-2" { + source = "./SNS" + + aws_region = "us-east-2" + aws_sns_topic_name = var.aws_sns_topic_name + providers = { + aws = aws.us-east-2 + } } -module "sns_topics" { - source = "AWS-Multi-Region-Deployment/SNS" + +module "us-west-1" { + source = "./SNS" + + aws_region = "us-west-1" + aws_sns_topic_name = var.aws_sns_topic_name + providers = { + aws = aws.us-west-1 + } } + +module "us-west-2" { + source = "./SNS" + + aws_region = "us-west-2" + aws_sns_topic_name = var.aws_sns_topic_name + providers = { + aws = aws.us-west-2 + } +} \ No newline at end of file diff --git a/AWS-Multi-Region-Deployment/providers.tf b/AWS-Multi-Region-Deployment/providers.tf new file mode 100644 index 0000000..37d4aa0 --- /dev/null +++ b/AWS-Multi-Region-Deployment/providers.tf @@ -0,0 +1,18 @@ +provider "aws" { + region = "us-east-1" +} + +provider "aws" { + alias = "us-east-2" + region = "us-east-2" +} + +provider "aws" { + alias = "us-west-1" + region = "us-west-1" +} + +provider "aws" { + alias = "us-west-2" + region = "us-west-2" +} \ No newline at end of file diff --git a/AWS-Multi-Region-Deployment/variables.tf b/AWS-Multi-Region-Deployment/variables.tf index 49f7608..d8e0fa4 100644 --- a/AWS-Multi-Region-Deployment/variables.tf +++ b/AWS-Multi-Region-Deployment/variables.tf @@ -1,9 +1,4 @@ -variable "aws_regions" { - type = list(string) - default = ["us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1"] -} - variable "aws_sns_topic_name" { type = string default = "cloud_quick_labs_sns" -} \ No newline at end of file +}