sparse-intern-71089
01/31/2022, 12:47 PMancient-monkey-64322
01/31/2022, 12:47 PMawsx.ec2.Vpc
using fromExistingIds
using a StackReference
The example in the examples repo works because it only passes in the vpcId
which is referenced as `networkingStack.getOutput("appVpcId")`(github link 🔗 ). This is an Output<string>
which is happily accepted by (property) ExistingVpcIdArgs.vpcId: pulumi.Input_<_string_>_
However, if I want to pass properties that expect an array (eg (property) ExistingVpcIdArgs.natGatewayIds_?:_ pulumi.Input_<_string_>_[] _|_ undefined
) then the only way I can see to do this is:
const vpcId: pulumi.Input<string> = sharedInfraStack.requireOutput("vpcId");
const internetGatewayId: pulumi.Input<string> = sharedInfraStack.requireOutput(
"vpcInternetGatewayId"
);
const natGatewayId: pulumi.Input<string> =
sharedInfraStack.requireOutput("vpcNatGatewayId");
const privateSubnetIdA: pulumi.Input<string> = sharedInfraStack.requireOutput(
"vpcPrivateSubnetIdA"
);
const privateSubnetIdB: pulumi.Input<string> = sharedInfraStack.requireOutput(
"vpcPrivateSubnetIdB"
);
const publicSubnetIdA: pulumi.Input<string> =
sharedInfraStack.requireOutput("vpcPublicSubnetIdA");
const publicSubnetIdB: pulumi.Input<string> =
sharedInfraStack.requireOutput("vpcPublicSubnetIdB");
awsx.ec2.Vpc.fromExistingIds("shared-vpc", {
vpcId,
internetGatewayId,
natGatewayIds: [natGatewayId],
privateSubnetIds: [privateSubnetIdA, privateSubnetIdB],
publicSubnetIds: [publicSubnetIdA, publicSubnetIdB],
});
ancient-monkey-64322
01/31/2022, 12:49 PMawsx.ec2.Vpc.fromExistingIds("shared-vpc", sharedInfraStack.requireOutput("vpcConfig").apply(configAsStr => JSON.parse(configAsStr)))
ancient-monkey-64322
01/31/2022, 12:51 PMsharedInfraStack.requireOutput("vpcConfig").apply(configAsStr =>
awsx.ec2.Vpc.fromExistingIds("shared-vpc", JSON.parse(configAsStr))
)
But then the rest of my application has to deal with Output<awsx.ec2.Vpc>
instead of awsx.ec2.Vpc
ancient-monkey-64322
01/31/2022, 12:52 PMmillions-furniture-75402
01/31/2022, 3:30 PMany
😖millions-furniture-75402
01/31/2022, 3:32 PMexport interface ExistingVpcArgs extends BaseArgs {
privateSubnetIds: Input<Input<string>[]>;
publicSubnetIds: Input<Input<string>[]>;
vpcId: Input<string>;
}
export class ExistingVpc extends BaseComponentResource {
vpc: any;
constructor(name: string, args: ExistingVpcArgs, opts?: ComponentResourceOptions) {
super("shared-vpc", name, args, opts);
this.vpc = all([args.publicSubnetIds, args.privateSubnetIds, args.vpcId]).apply(
([publicSubnetIds, privateSubnetIds, vpcId]) => {
return awsx.ec2.Vpc.fromExistingIds(this.getName(), {
vpcId,
publicSubnetIds,
privateSubnetIds,
});
},
);
}
}
millions-furniture-75402
01/31/2022, 3:35 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by