flaky-pizza-91785
08/14/2024, 4:39 PMfunc PulumiOps(program func(ctx *pulumi.Context) error, project_name, stack_name, region string, vpcProgram pulumi.RunFunc, ctx context.Context) (auto.OutputMap, error) {
stack, err := auto.UpsertStackInlineSource(ctx, stack_name, project_name, vpcProgram)
if err != nil {
logrus.Error("Could not create stack: ", err)
return auto.OutputMap{}, err
}
err = stack.SetConfig(ctx, "aws:region", auto.ConfigValue{Value: region})
if err != nil {
logrus.Error("Could not set config: ", err)
return auto.OutputMap{}, err
}
// Create a new VPC with a public and private subnet.
func A(ctx *pulumi.Context) err
vpc, err := awsx.NewVpc(ctx, project_name, &awsx.VpcArgs{
CidrBlock: pulumi.StringRef("10.0.0.0/16"),
Tags: pulumi.StringMap{
"Name": pulumi.String(project_name),
},
NumberOfAvailabilityZones: pulumi.IntRef(4),
SubnetSpecs: []awsx.SubnetSpecArgs{
{
<other args>
ctx.Export("vpcId", vpc.VpcId)
func B(ctx *pulumi.Context) err
// Create an EKS cluster.
cluster, err := eks.NewCluster(ctx, project_name, &eks.ClusterArgs{
InstanceType: pulumi.String(eksNodeInstanceType),
VpcId: pulumi.Sprintf( vpcid),
PublicSubnetIds: vpc.PublicSubnetIds ,
PrivateSubnetIds: vpc.PrivateSubnetIds ,
MinSize: <http://pulumi.Int|pulumi.Int>(minClusterSize),
MaxSize: <http://pulumi.Int|pulumi.Int>(maxClusterSize),
DesiredCapacity: <http://pulumi.Int|pulumi.Int>(desiredClusterSize),
NodeAssociatePublicIpAddress: pulumi.BoolRef(false),
<other args>
ctx.Export("kubeconfig", cluster.kubeconfig)
So whenever I create VPC with
PulumiOps(.... B...) //snippet ---> This create the vpc correctly and I get the vpc id
Then the next time I want to create eks or any other resource using
Pulumi(...A...) ----->>> This subsequent resource deletes everything that was created by vpc.
The requirement is to call func A first. Wait for to finish then somewhere else, func B is called and provided with vpcid from func A.
func A works perfect, func B deletes all the resources
That works perfectly, I get vpc id and store it somewhere
Why is this happening and how can I fix it. Thank you very much.No 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