Skip to content

Commit

Permalink
Merge pull request #19 from theonestack/feature/custom-exports
Browse files Browse the repository at this point in the history
add custom export names
  • Loading branch information
tarunmenon95 authored Sep 5, 2024
2 parents ddf31c7 + da4f9d7 commit a1278e4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions vpc-v2.cfndsl.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'ipaddr'

CloudFormation do

export = external_parameters.fetch(:export_name, external_parameters[:component_name])

tags = external_parameters.fetch(:tags, {})

Expand Down Expand Up @@ -42,17 +44,17 @@

Output(:VPCId) {
Value(Ref(:VPC))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-VPCId")
Export FnSub("${EnvironmentName}-#{export}-VPCId")
}

Output(:VPCCidr) {
Value(FnGetAtt(:VPC, :CidrBlock))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-VPCCidr")
Export FnSub("${EnvironmentName}-#{export}-VPCCidr")
}

Output(:DefaultSecurityGroup) {
Value(FnGetAtt(:VPC, :DefaultSecurityGroup))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-DefaultSecurityGroup")
Export FnSub("${EnvironmentName}-#{export}-DefaultSecurityGroup")
}

if external_parameters[:enable_dhcp]
Expand Down Expand Up @@ -85,7 +87,7 @@
}
Output(:PublicRouteTableIds) {
Value(Ref(:RouteTablePublic))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-PublicRouteTableIds")
Export FnSub("${EnvironmentName}-#{export}-PublicRouteTableIds")
}

EC2_NetworkAcl(:NetworkAclPublic) {
Expand Down Expand Up @@ -565,7 +567,7 @@

Output(:PrivateRouteTableIds) {
Value(FnJoin(",",route_tables))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-PrivateRouteTableIds")
Export FnSub("${EnvironmentName}-#{export}-PrivateRouteTableIds")
}

##
Expand Down Expand Up @@ -639,7 +641,7 @@

Output("#{cfg['name']}Subnets") {
Value(FnJoin(',', subnet_grp_condition))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-#{cfg['name']}Subnets")
Export FnSub("${EnvironmentName}-#{export}-#{cfg['name']}Subnets")
}

subnet_groups[cfg['name']] = subnet_grp_condition
Expand Down Expand Up @@ -667,7 +669,7 @@

Output(:S3VPCEndpointId) {
Value(Ref(:S3VpcEndpoint))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-S3VPCEndpointId")
Export FnSub("${EnvironmentName}-#{export}-S3VPCEndpointId")
}

EC2_VPCEndpoint(:DynamodbVpcEndpoint) {
Expand All @@ -678,7 +680,7 @@

Output(:DynamodbVPCEndpointId) {
Value(Ref(:DynamodbVpcEndpoint))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-DynamodbVPCEndpointId")
Export FnSub("${EnvironmentName}-#{export}-DynamodbVPCEndpointId")
}

endpoints = external_parameters.fetch(:endpoints, [])
Expand Down Expand Up @@ -718,7 +720,7 @@

Output("#{vpce.capitalize}VPCEndpointId") {
Value(Ref("#{vpce.capitalize}VpcEndpoint"))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-#{vpce.capitalize}VPCEndpointId")
Export FnSub("${EnvironmentName}-#{export}-#{vpce.capitalize}VPCEndpointId")
}
end
end
Expand Down Expand Up @@ -820,7 +822,7 @@

Output(:HostedZone) {
Value(Ref(:HostedZone))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-hosted-zone")
Export FnSub("${EnvironmentName}-#{export}-hosted-zone")
}
end

Expand Down

0 comments on commit a1278e4

Please sign in to comment.