Hello, I would need help if possible. I try to mig...
# aws
b
Hello, I would need help if possible. I try to migrate a platform using "@pulumi/aws": "^6.82.1" to "@pulumi/aws": "^7.7.0". I have an issue with routes. I get this error: * updating urnpulumilha:ridgelineawsec2/routeRouteeu west 1 to us east 1 rtb 0782fa3485885fc00 1 error occurred: * route target attribute not specified The code looks like:
Copy code
new aws.ec2.Route(
  `${regionNameFrom}-to-${regionNameTo}-${routeTableId}`,
  {
    routeTableId: routeTableId,
    destinationCidrBlock: cidr,
    vpcPeeringConnectionId: vpcPeeringConnectionId,
  },
  { dependsOn: peerVpcPeeringConnection, provider },
);
every parameter has the correct value and the provider is defined I am blocked and cannot upgrade pulumi
m
Hey @bumpy-laptop-30846 Can you share more of the pulumi code? The VpcPeeringConnection, and providers and route?
b
sure, here it is
Copy code
import * as aws from '@pulumi/aws';
import * as pulumi from '@pulumi/pulumi';
import { RidgelineCluster } from './region-cluster';
import { isDryRun } from '@pulumi/pulumi/runtime';
import { getOutputPromise } from '../common/pulumi.utils';

export const deployRegionPeering = async (region: RidgelineCluster, regionConfigMain: RidgelineCluster) => {
  await <http://pulumi.log.info|pulumi.log.info>(`Installing vpc peering for ${region.region.name} -> ${regionConfigMain.region.name}`);

  const providerMainRegion = new aws.Provider('providerMainRegion', {
    region: regionConfigMain.region.name,
  });

  const peerCallerIdentity = await aws.getCallerIdentity({}, { provider: region.awsRegionProvider });

  const peerVpcPeeringConnection = new aws.ec2.VpcPeeringConnection(
    `peerVpcPeeringConnection-${region.region.name}`,
    {
      vpcId: region.vpc.id,
      peerVpcId: regionConfigMain.vpc.id,
      peerOwnerId: peerCallerIdentity.accountId,
      peerRegion: regionConfigMain.region.name,
      autoAccept: false,
      tags: { Side: 'Requester' },
    },
    { provider: region.awsRegionProvider },
  );

  const peerVpcPeeringConnectionAccepter = new aws.ec2.VpcPeeringConnectionAccepter(
    `peerVpcPeeringConnectionAccepter-${region.region.name}`,
    {
      vpcPeeringConnectionId: peerVpcPeeringConnection.id,
      accepter: { allowRemoteVpcDnsResolution: true },
      autoAccept: true,
      tags: { Side: 'Accepter' },
    },
    { dependsOn: peerVpcPeeringConnection, provider: providerMainRegion },
  );

  if (!isDryRun()) {
    const outputVpcPeeringConnectionAccepter = await getOutputPromise(peerVpcPeeringConnectionAccepter.acceptStatus);
    console.log(`VPC peering connection status : ${outputVpcPeeringConnectionAccepter}`);
  }

  createVpcPeeringRoutes(
    region.vpc.publicSubnetRouteTables!,
    region.region.name,
    regionConfigMain.region.name,
    regionConfigMain.vpc.cidrBlock,
    peerVpcPeeringConnection,
    region.awsRegionProvider!,
  );
  createVpcPeeringRoutes(
    regionConfigMain.vpc.publicSubnetRouteTables!,
    regionConfigMain.region.name,
    region.region.name,
    region.vpc.cidrBlock,
    peerVpcPeeringConnection,
    providerMainRegion
  );

  // for monolith NLB which can be created in private subnet
  createVpcPeeringRoute(
    region.vpc.cidrBlock,
    regionConfigMain.vpc.mainRouteTableId,
    regionConfigMain.region.name,
    region.region.name,
    peerVpcPeeringConnection,
    providerMainRegion
  );
};

const createVpcPeeringRoutes = (
  routeTables: aws.ec2.RouteTable[],
  regionNameFrom: string,
  regionNameTo: string,
  cidr: pulumi.Output<string>,
  peerVpcPeeringConnection: aws.ec2.VpcPeeringConnection,
  provider: aws.Provider,
) => {
  routeTables.forEach((routeTable) => {
    createVpcPeeringRoute(cidr, routeTable.id, regionNameFrom, regionNameTo, peerVpcPeeringConnection, provider);
  });
};

const createVpcPeeringRoute = (
  cidr: pulumi.Output<string>,
  routeTableId: pulumi.Output<string>,
  regionNameFrom: string,
  regionNameTo: string,
  peerVpcPeeringConnection: aws.ec2.VpcPeeringConnection,
  provider: aws.Provider,
) => {
  pulumi
    .all([cidr, routeTableId, peerVpcPeeringConnection.id])
    .apply(([cidr, routeTableId, vpcPeeringConnectionId]) => {
      <http://pulumi.log.info|pulumi.log.info>(`Installing vpc route ${regionNameFrom} -> ${regionNameTo} ${cidr} in table ${routeTableId} for vpc peering ${vpcPeeringConnectionId}`);
      if (!cidr || !routeTableId || !vpcPeeringConnectionId) {
        pulumi.log.warn(
          `Skipping route creation: missing values (cidr: ${cidr}, routeTableId: ${routeTableId}, vpcPeeringConnectionId: ${vpcPeeringConnectionId})`,
        );
        return;
      }
      new aws.ec2.Route(
        `${regionNameFrom}-to-${regionNameTo}-${routeTableId}`,
        {
          routeTableId: routeTableId,
          destinationCidrBlock: cidr,
          vpcPeeringConnectionId: vpcPeeringConnectionId,
        },
        { dependsOn: peerVpcPeeringConnection, provider },
      );
    });
};
m
I think you may need to dependon your peerVpcPeeringConnectionAccepter when you create each of your routes, so that it waits for it to complete.
b
Hi Adam, I tried but the result is the same. Only the migration causes this issue. Creating from scratch works fine. I do a pulumi refresh before the up with the latest version as indicated. if I put a breakpoint in the apply function I get all the correct ids.
m
Interesting. I wonder if you could use a
Copy code
--replace stringArray
to force recreation? Let me see if anyone more knowledgable then myself might have a real answer.