This message was deleted.
# aws
s
This message was deleted.
g
@brave-planet-10645 👋 Have you ever seen or run into the above? Currently blocking us 😕
b
Can you provide the code for
myLambdaFunction
please?
I've just put together a quick demo that you can take a look at here: https://github.com/pierskarsenbarg/pulumi-scratchpad/tree/main/apigatewaylambda
That works for me
The main part is in the index.ts file
h
thanks! I'll check it out and tell you if my version works with your example
Hey, so using you're example I'm still getting the same error. Here's the code:
Copy code
import { LocalWorkspace } from '@pulumi/pulumi/x/automation';
import * as aws from '@pulumi/aws';
import * as awsx from '@pulumi/awsx';
import * as pulumi from '@pulumi/pulumi';

export async function standup(): Promise<void> {
  const pulumiProgram = async (): Promise<any> => {
    const role = new aws.iam.Role('ruleReportsFuncRole', {
      assumeRolePolicy: {
        Version: '2012-10-17',
        Statement: [
          {
            Action: 'sts:AssumeRole',
            Principal: {
              Service: '<http://lambda.amazonaws.com|lambda.amazonaws.com>'
            },
            Effect: 'Allow',
            Sid: ''
          }
        ]
      }
    });

    const rolePolicyAttachment = new aws.iam.RolePolicyAttachment('rpa', {
      policyArn: aws.iam.ManagedPolicy.LambdaFullAccess,
      role: role
    });

    const lambdaFunction = new aws.lambda.Function('lambdafunction', {
      code: new pulumi.asset.AssetArchive({
        '.': new pulumi.asset.FileArchive('./app')
      }),
      role: role.arn,
      handler: 'index.lambdaCode',
      runtime: 'nodejs14.x'
    });

    const gateway = new awsx.apigateway.API(`my-lambda-gateway`, {
      routes: [
        {
          path: '/myLambdaFunction',
          method: 'POST',
          eventHandler: lambdaFunction
        }
      ]
    });

    return {
      url: gateway.url
    };
  };

  const args = {
    stackName: `myCompany/development-myusername-integration-my-lambda`,
    projectName: 'myCompany-my-project',
    program: pulumiProgram,
    workDir: '.'
  };

  const stack = await LocalWorkspace.createOrSelectStack(args);
  await stack.workspace.installPlugin('aws', 'v3.6.1');
  await stack.setConfig('aws:region', { value: 'us-east-2' });
  await stack.refresh({ onOutput: <http://console.info|console.info> });
  await stack.up({ onOutput: <http://console.info|console.info> });
}
and here's the error:
Copy code
Diagnostics:
  pulumi:pulumi:Stack (myCompany-my-project-development-myusername-integration-my-lambda):
    error: update failed
 
  aws:apigateway:RestApi (my-lambda-gateway):

    error: 1 error occurred:
        * creating urn:pulumi:development-myusername-integration-my-lambda::myCompany-my-project::aws:apigateway:x:API$aws:apigateway/restApi:RestApi::my-lambda-gateway: 1 error occurred:
        * error creating API Gateway specification: BadRequestException: Errors found during import:
        Unable to put integration on 'POST' for resource at path '/myLambdaFunction': Invalid ARN specified in the request
    error: post-step event returned an error: failed to verify snapshot: resource urn:pulumi:development-myusername-integration-my-lambda::myCompany-my-project::aws:apigateway:x:API$aws:apigateway/restApi:RestApi::my-lambda-gateway dependency  refers to missing resource
b
Sorry, I missed that you're using automation api. There is a bug when using apigateway from awsx and automation api: https://github.com/pulumi/pulumi/issues/6162
In fact, it was opened by @gifted-terabyte-92288 by the looks of things
g
Yeah - looks to be a similar issue. Thank you for the help, Piers.