Skip to content

Commit

Permalink
Update requested for Proton - environment/vpc-env-tf-actions-prod3
Browse files Browse the repository at this point in the history
  • Loading branch information
sbx_user1051 committed Apr 25, 2024
1 parent 50629b7 commit 8bd24c5
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vpc-env-tf-actions-prod3/.proton/deployment-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"deploymentId" : "97a2e74f-7fce-4bae-9188-9899078cbf3f",
"isResourceDeleted" : false,
"resourceMetadata" : {
"arn" : "arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3",
"templateArn" : "arn:aws:proton:us-east-1:527207589752:environment-template/vpc-env",
"templateMajorVersion" : "1",
"templateMinorVersion" : "2"
}
}
33 changes: 33 additions & 0 deletions vpc-env-tf-actions-prod3/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.4.0"
}
}

backend "s3" {}
}

# Configure the AWS Provider
provider "aws" {
region = var.aws_region
default_tags {
tags = {
proton:environment = var.environment.name
}
}
}

variable "aws_region" {
type = string
default = "us-east-1"
}
44 changes: 44 additions & 0 deletions vpc-env-tf-actions-prod3/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

data "aws_region" "current" {}

data "aws_caller_identity" "current" {}

data "aws_partition" "current" {}

data "aws_availability_zones" "available" {
state = "available"
}

resource "aws_sns_topic_policy" "default" {
arn = aws_sns_topic.ping_topic.arn

policy = data.aws_iam_policy_document.ping_topic_policy.json
}

data "aws_iam_policy_document" "ping_topic_policy" {
statement {
effect = "Allow"

actions = ["sns:Subscribe"]

condition {
test = "StringEquals"
variable = "sns:Protocol"
values = ["sqs"]
}

principals {
identifiers = ["arn:${local.partition}:iam::${local.account_id}:root"]
type = "AWS"
}

resources = [aws_sns_topic.ping_topic.arn]
}
}
13 changes: 13 additions & 0 deletions vpc-env-tf-actions-prod3/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

locals {
account_id = data.aws_caller_identity.current.account_id
region = data.aws_region.current.id
partition = data.aws_partition.current.id
}
49 changes: 49 additions & 0 deletions vpc-env-tf-actions-prod3/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

module "vpc" {
source = "terraform-aws-modules/vpc/aws"

cidr = var.environment.inputs.vpc_cidr

azs = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1]]
private_subnets = [
var.environment.inputs.private_subnet_one_cidr,
var.environment.inputs.private_subnet_two_cidr
]
public_subnets = [var.environment.inputs.public_subnet_one_cidr, var.environment.inputs.public_subnet_two_cidr]
enable_nat_gateway = true
enable_vpn_gateway = true
enable_dns_hostnames = true
enable_dns_support = true

tags = {
Terraform = "true"
Environment = var.environment.name
}
}

resource "aws_vpc_endpoint" "ec2" {
service_name = "com.amazonaws.${local.region}.sns"
vpc_id = module.vpc.vpc_id
private_dns_enabled = true
vpc_endpoint_type = "Interface"
security_group_ids = [module.vpc.default_security_group_id]
subnet_ids = module.vpc.public_subnets
}

resource "aws_apprunner_vpc_connector" "connector" {
vpc_connector_name = "${var.environment.name}-vpc-connector"
subnets = module.vpc.public_subnets
security_groups = [module.vpc.default_security_group_id]
}

resource "aws_sns_topic" "ping_topic" {
name_prefix = "ping-"
kms_master_key_id = "alias/aws/sns"
}
47 changes: 47 additions & 0 deletions vpc-env-tf-actions-prod3/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

output "SnsTopicArn" {
value = aws_sns_topic.ping_topic.arn
}

output "SnsTopicName" {
value = aws_sns_topic.ping_topic.name
}

output "SnsRegion" {
value = local.region
}

output "VpcId" {
value = module.vpc.vpc_id
}

output "PublicSubnetOneId" {
value = module.vpc.public_subnets[0]
}

output "PublicSubnetTwoId" {
value = module.vpc.public_subnets[1]
}

output "PrivateSubnetOneId" {
value = module.vpc.private_subnets[0]
}

output "PrivateSubnetTwoId" {
value = module.vpc.private_subnets[1]
}

output "VpcDefaultSecurityGroupId" {
value = module.vpc.default_security_group_id
}

output "VpcConnectorArn" {
value = aws_apprunner_vpc_connector.connector.id
}
18 changes: 18 additions & 0 deletions vpc-env-tf-actions-prod3/proton.auto.tfvars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"environment" : {
"name" : "vpc-env-tf-actions-prod3",
"inputs" : {
"vpc_cidr" : "10.0.0.0/16",
"public_subnet_one_cidr" : "10.0.0.0/18",
"public_subnet_two_cidr" : "10.0.64.0/18",
"private_subnet_one_cidr" : "10.0.128.0/18",
"private_subnet_two_cidr" : "10.0.192.0/18"
}
},
"proton_tags" : {
"proton:account" : "527207589752",
"proton:template" : "arn:aws:proton:us-east-1:527207589752:environment-template/vpc-env",
"proton:environment" : "arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3"
},
"//" : "arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3"
}
20 changes: 20 additions & 0 deletions vpc-env-tf-actions-prod3/proton.environment.variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
This file is managed by AWS Proton. Any changes made directly to this file will be overwritten the next time AWS Proton performs an update.
To manage this resource, see AWS Proton Resource: arn:aws:proton:us-east-1:527207589752:environment/vpc-env-tf-actions-prod3
If the resource is no longer accessible within AWS Proton, it may have been deleted and may require manual cleanup.
*/

variable "environment" {
type = object({
inputs = any
name = string
})
default = null
}

variable "proton_tags" {
type = map(string)
default = null
}

0 comments on commit 8bd24c5

Please sign in to comment.