Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose route table ids #885

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
## HEAD (Unreleased)
* Add multi-lang component support scaffolding.
* Fix type errors in TypeScript checking awsx-classic properties.
* Expose all route table ids as outputs
[#885](https://github.com/pulumi/pulumi-awsx/pull/885)

## 0.40.0 (2022-03-24)
* Compatibility with pulumi-aws v5.0.0
Expand Down
31 changes: 31 additions & 0 deletions awsx/ec2/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ interface VpcData {
routeTables: aws.ec2.RouteTable[];
routes: aws.ec2.Route[];
routeTableAssociations: aws.ec2.RouteTableAssociation[];
privateRouteTableIds: pulumi.Output<string>[];
publicRouteTableIds: pulumi.Output<string>[];
isolatedRouteTableIds: pulumi.Output<string>[];
igw: aws.ec2.InternetGateway;
natGateways: aws.ec2.NatGateway[];
eips: aws.ec2.Eip[];
Expand All @@ -44,6 +47,9 @@ export class Vpc extends schema.Vpc<VpcData> {
this.routeTables = data.routeTables;
this.routes = data.routes;
this.routeTableAssociations = data.routeTableAssociations;
this.privateRouteTableIds = data.privateRouteTableIds;
this.publicRouteTableIds = data.publicRouteTableIds;
this.isolatedSubnetIds = data.isolatedSubnetIds;
this.internetGateway = data.igw;
this.natGateways = data.natGateways;
this.eips = data.eips;
Expand Down Expand Up @@ -118,6 +124,9 @@ export class Vpc extends schema.Vpc<VpcData> {
const subnets: aws.ec2.Subnet[] = [];
const routeTables: aws.ec2.RouteTable[] = [];
const routeTableAssociations: aws.ec2.RouteTableAssociation[] = [];
const privateRouteTableIds: pulumi.Output<string>[] = [];
const publicRouteTableIds: pulumi.Output<string>[] = [];
const isolatedRouteTableIds: pulumi.Output<string>[] = [];
const routes: aws.ec2.Route[] = [];
const natGateways: aws.ec2.NatGateway[] = [];
const eips: aws.ec2.Eip[] = [];
Expand Down Expand Up @@ -186,6 +195,25 @@ export class Vpc extends schema.Vpc<VpcData> {
);
routeTables.push(routeTable);

// populate routeTableIds
switch (spec.type.toLowerCase()) {
case "public": {
publicRouteTableIds.push(routeTable.id);
break;
}
case "private": {
privateRouteTableIds.push(routeTable.id);
break;
}
case "isolated": {
isolatedRouteTableIds.push(routeTable.id);
break;
}
default: {
break;
}
}

const routeTableAssoc = new aws.ec2.RouteTableAssociation(
spec.subnetName,
{
Expand Down Expand Up @@ -268,6 +296,9 @@ export class Vpc extends schema.Vpc<VpcData> {
igw,
routeTables,
routeTableAssociations,
privateRouteTableIds,
publicRouteTableIds,
isolatedRouteTableIds,
routes,
natGateways,
eips,
Expand Down
5 changes: 4 additions & 1 deletion awsx/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ export abstract class Vpc<TData = any> extends pulumi.ComponentResource<TData> {
public privateSubnetIds!: string[] | pulumi.Output<string[]>;
public publicSubnetIds!: string[] | pulumi.Output<string[]>;
public routeTableAssociations!: aws.ec2.RouteTableAssociation[] | pulumi.Output<aws.ec2.RouteTableAssociation[]>;
public publicRouteTableIds!: string[] | pulumi.Output<string[]>;
public privateRouteTableIds!: string[] | pulumi.Output<string[]>;
public isolatedRouteTableIds!: string[] | pulumi.Output<string[]>;
public routeTables!: aws.ec2.RouteTable[] | pulumi.Output<aws.ec2.RouteTable[]>;
public routes!: aws.ec2.Route[] | pulumi.Output<aws.ec2.Route[]>;
public subnets!: aws.ec2.Subnet[] | pulumi.Output<aws.ec2.Subnet[]>;
public vpc!: aws.ec2.Vpc | pulumi.Output<aws.ec2.Vpc>;
public vpcEndpoints!: aws.ec2.VpcEndpoint[] | pulumi.Output<aws.ec2.VpcEndpoint[]>;
public vpcId!: string | pulumi.Output<string>;
constructor(name: string, args: pulumi.Inputs, opts: pulumi.ComponentResourceOptions = {}) {
super("awsx:ec2:Vpc", name, opts.urn ? { eips: undefined, internetGateway: undefined, isolatedSubnetIds: undefined, natGateways: undefined, privateSubnetIds: undefined, publicSubnetIds: undefined, routeTableAssociations: undefined, routeTables: undefined, routes: undefined, subnets: undefined, vpc: undefined, vpcEndpoints: undefined, vpcId: undefined } : { name, args, opts }, opts);
super("awsx:ec2:Vpc", name, opts.urn ? { eips: undefined, internetGateway: undefined, isolatedSubnetIds: undefined, natGateways: undefined, privateSubnetIds: undefined, publicSubnetIds: undefined, routeTableAssociations: undefined, publicRouteTableIds: undefined, privateRouteTableIds: undefined, isolatedRouteTableIds: undefined, routeTables: undefined, routes: undefined, subnets: undefined, vpc: undefined, vpcEndpoints: undefined, vpcId: undefined } : { name, args, opts }, opts);
}
}
export interface VpcArgs {
Expand Down
21 changes: 21 additions & 0 deletions awsx/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,24 @@
},
"description": "The Route Table Associations for the VPC."
},
"publicRouteTableIds": {
"type": "array",
"items": {
"type": "string"
}
},
"privateRouteTableIds": {
"type": "array",
"items": {
"type": "string"
}
},
"isolatedRouteTableIds": {
"type": "array",
"items": {
"type": "string"
}
},
Comment on lines +1692 to +1709
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema.json is generated by the schemagen program. The VPC types are defined using this code here: https://github.com/pulumi/pulumi-awsx/blob/master/schemagen/pkg/gen/ec2.go

"routeTables": {
"type": "array",
"items": {
Expand Down Expand Up @@ -1736,6 +1754,9 @@
"routeTables",
"routeTableAssociations",
"routes",
"privateRouteTableIds",
"publicRouteTableIds",
"isolatedRouteTableIds",
"internetGateway",
"natGateways",
"eips",
Expand Down
9 changes: 9 additions & 0 deletions sdk/dotnet/Ec2/Vpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public partial class Vpc : Pulumi.ComponentResource
[Output("internetGateway")]
public Output<Pulumi.Aws.Ec2.InternetGateway> InternetGateway { get; private set; } = null!;

[Output("isolatedRouteTableIds")]
public Output<ImmutableArray<string>> IsolatedRouteTableIds { get; private set; } = null!;

[Output("isolatedSubnetIds")]
public Output<ImmutableArray<string>> IsolatedSubnetIds { get; private set; } = null!;

Expand All @@ -33,9 +36,15 @@ public partial class Vpc : Pulumi.ComponentResource
[Output("natGateways")]
public Output<ImmutableArray<Pulumi.Aws.Ec2.NatGateway>> NatGateways { get; private set; } = null!;

[Output("privateRouteTableIds")]
public Output<ImmutableArray<string>> PrivateRouteTableIds { get; private set; } = null!;

[Output("privateSubnetIds")]
public Output<ImmutableArray<string>> PrivateSubnetIds { get; private set; } = null!;

[Output("publicRouteTableIds")]
public Output<ImmutableArray<string>> PublicRouteTableIds { get; private set; } = null!;

[Output("publicSubnetIds")]
public Output<ImmutableArray<string>> PublicSubnetIds { get; private set; } = null!;

Expand Down
25 changes: 20 additions & 5 deletions sdk/go/awsx/ec2/vpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions sdk/java/src/main/java/com/pulumi/awsx/ec2/Vpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public Output<List<Eip>> eips() {
public Output<InternetGateway> internetGateway() {
return this.internetGateway;
}
@Export(name="isolatedRouteTableIds", type=List.class, parameters={String.class})
private Output<List<String>> isolatedRouteTableIds;

public Output<List<String>> isolatedRouteTableIds() {
return this.isolatedRouteTableIds;
}
@Export(name="isolatedSubnetIds", type=List.class, parameters={String.class})
private Output<List<String>> isolatedSubnetIds;

Expand All @@ -71,12 +77,24 @@ public Output<List<String>> isolatedSubnetIds() {
public Output<List<NatGateway>> natGateways() {
return this.natGateways;
}
@Export(name="privateRouteTableIds", type=List.class, parameters={String.class})
private Output<List<String>> privateRouteTableIds;

public Output<List<String>> privateRouteTableIds() {
return this.privateRouteTableIds;
}
@Export(name="privateSubnetIds", type=List.class, parameters={String.class})
private Output<List<String>> privateSubnetIds;

public Output<List<String>> privateSubnetIds() {
return this.privateSubnetIds;
}
@Export(name="publicRouteTableIds", type=List.class, parameters={String.class})
private Output<List<String>> publicRouteTableIds;

public Output<List<String>> publicRouteTableIds() {
return this.publicRouteTableIds;
}
@Export(name="publicSubnetIds", type=List.class, parameters={String.class})
private Output<List<String>> publicSubnetIds;

Expand Down
9 changes: 9 additions & 0 deletions sdk/nodejs/ec2/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ export class Vpc extends pulumi.ComponentResource {
* The Internet Gateway for the VPC.
*/
public /*out*/ readonly internetGateway!: pulumi.Output<pulumiAws.ec2.InternetGateway>;
public /*out*/ readonly isolatedRouteTableIds!: pulumi.Output<string[]>;
public /*out*/ readonly isolatedSubnetIds!: pulumi.Output<string[]>;
/**
* The NAT Gateways for the VPC. If no NAT Gateways are specified, this will be an empty list.
*/
public readonly natGateways!: pulumi.Output<pulumiAws.ec2.NatGateway[]>;
public /*out*/ readonly privateRouteTableIds!: pulumi.Output<string[]>;
public /*out*/ readonly privateSubnetIds!: pulumi.Output<string[]>;
public /*out*/ readonly publicRouteTableIds!: pulumi.Output<string[]>;
public /*out*/ readonly publicSubnetIds!: pulumi.Output<string[]>;
/**
* The Route Table Associations for the VPC.
Expand Down Expand Up @@ -95,8 +98,11 @@ export class Vpc extends pulumi.ComponentResource {
resourceInputs["vpcEndpointSpecs"] = args ? args.vpcEndpointSpecs : undefined;
resourceInputs["eips"] = undefined /*out*/;
resourceInputs["internetGateway"] = undefined /*out*/;
resourceInputs["isolatedRouteTableIds"] = undefined /*out*/;
resourceInputs["isolatedSubnetIds"] = undefined /*out*/;
resourceInputs["privateRouteTableIds"] = undefined /*out*/;
resourceInputs["privateSubnetIds"] = undefined /*out*/;
resourceInputs["publicRouteTableIds"] = undefined /*out*/;
resourceInputs["publicSubnetIds"] = undefined /*out*/;
resourceInputs["routeTableAssociations"] = undefined /*out*/;
resourceInputs["routeTables"] = undefined /*out*/;
Expand All @@ -108,9 +114,12 @@ export class Vpc extends pulumi.ComponentResource {
} else {
resourceInputs["eips"] = undefined /*out*/;
resourceInputs["internetGateway"] = undefined /*out*/;
resourceInputs["isolatedRouteTableIds"] = undefined /*out*/;
resourceInputs["isolatedSubnetIds"] = undefined /*out*/;
resourceInputs["natGateways"] = undefined /*out*/;
resourceInputs["privateRouteTableIds"] = undefined /*out*/;
resourceInputs["privateSubnetIds"] = undefined /*out*/;
resourceInputs["publicRouteTableIds"] = undefined /*out*/;
resourceInputs["publicSubnetIds"] = undefined /*out*/;
resourceInputs["routeTableAssociations"] = undefined /*out*/;
resourceInputs["routeTables"] = undefined /*out*/;
Expand Down
18 changes: 18 additions & 0 deletions sdk/python/pulumi_awsx/ec2/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,11 @@ def _internal_init(__self__,
__props__.__dict__["vpc_endpoint_specs"] = vpc_endpoint_specs
__props__.__dict__["eips"] = None
__props__.__dict__["internet_gateway"] = None
__props__.__dict__["isolated_route_table_ids"] = None
__props__.__dict__["isolated_subnet_ids"] = None
__props__.__dict__["private_route_table_ids"] = None
__props__.__dict__["private_subnet_ids"] = None
__props__.__dict__["public_route_table_ids"] = None
__props__.__dict__["public_subnet_ids"] = None
__props__.__dict__["route_table_associations"] = None
__props__.__dict__["route_tables"] = None
Expand Down Expand Up @@ -493,6 +496,11 @@ def internet_gateway(self) -> pulumi.Output['pulumi_aws.ec2.InternetGateway']:
"""
return pulumi.get(self, "internet_gateway")

@property
@pulumi.getter(name="isolatedRouteTableIds")
def isolated_route_table_ids(self) -> pulumi.Output[Sequence[str]]:
return pulumi.get(self, "isolated_route_table_ids")

@property
@pulumi.getter(name="isolatedSubnetIds")
def isolated_subnet_ids(self) -> pulumi.Output[Sequence[str]]:
Expand All @@ -506,11 +514,21 @@ def nat_gateways(self) -> pulumi.Output[Sequence['pulumi_aws.ec2.NatGateway']]:
"""
return pulumi.get(self, "nat_gateways")

@property
@pulumi.getter(name="privateRouteTableIds")
def private_route_table_ids(self) -> pulumi.Output[Sequence[str]]:
return pulumi.get(self, "private_route_table_ids")

@property
@pulumi.getter(name="privateSubnetIds")
def private_subnet_ids(self) -> pulumi.Output[Sequence[str]]:
return pulumi.get(self, "private_subnet_ids")

@property
@pulumi.getter(name="publicRouteTableIds")
def public_route_table_ids(self) -> pulumi.Output[Sequence[str]]:
return pulumi.get(self, "public_route_table_ids")

@property
@pulumi.getter(name="publicSubnetIds")
def public_subnet_ids(self) -> pulumi.Output[Sequence[str]]:
Expand Down