NEW: sharing transit gateway via RAM
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
output vpc-id {
|
||||
value = data.aws_vpc.vpc1.id
|
||||
}
|
||||
|
||||
output share-name {
|
||||
value = aws_ram_resource_share_accepter.tgw-accepter.share_name
|
||||
}
|
||||
|
||||
output share-status {
|
||||
value = aws_ram_resource_share_accepter.tgw-accepter.status
|
||||
}
|
||||
|
||||
output shared-resources {
|
||||
value = aws_ram_resource_share_accepter.tgw-accepter.resources
|
||||
}
|
||||
|
||||
output tgw-id {
|
||||
value = data.aws_ec2_transit_gateway.shared-tgw.id
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
provider "aws" {
|
||||
region = var.aws-region
|
||||
access_key = var.aws_access_key
|
||||
secret_key = var.aws_secret_key
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_version = "> 0.12, < 0.13"
|
||||
required_providers {
|
||||
aws = "~> 3.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
resource "aws_ram_resource_share_accepter" "tgw-accepter" {
|
||||
share_arn = "arn:aws:ram:ap-southeast-1:573340405480:resource-share/70e66c50-c169-4f31-a199-f3a09adb27ce"
|
||||
lifecycle {
|
||||
ignore_changes = all
|
||||
}
|
||||
}
|
||||
|
||||
locals {
|
||||
tgw-id = split("/", aws_ram_resource_share_accepter.tgw-accepter.resources[0])[1]
|
||||
}
|
||||
|
||||
data "aws_ec2_transit_gateway" shared-tgw {
|
||||
id = local.tgw-id
|
||||
}
|
||||
|
||||
data "aws_subnet_ids" subnet-ids {
|
||||
vpc_id = data.aws_vpc.vpc1.id
|
||||
}
|
||||
|
||||
resource "aws_ec2_transit_gateway_vpc_attachment" tgw-attach {
|
||||
vpc_id = data.aws_vpc.vpc1.id
|
||||
subnet_ids = [tolist(data.aws_subnet_ids.subnet-ids.ids)[0]]
|
||||
transit_gateway_id = data.aws_ec2_transit_gateway.shared-tgw.id
|
||||
tags = local.default-tags
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
variable "aws_access_key" {}
|
||||
variable "aws_secret_key" {}
|
||||
|
||||
variable aws-region {}
|
||||
variable owner {}
|
||||
variable project {}
|
||||
variable environment {}
|
||||
variable application {}
|
||||
variable terraformmode {}
|
||||
|
||||
locals {
|
||||
default-tags = {
|
||||
terraform = var.terraformmode
|
||||
environment = var.environment
|
||||
project = var.project
|
||||
application = var.application
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
data aws_vpc vpc1 {
|
||||
id = "vpc-d151e0b4"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user