amazon-archives/aws-appsync-rds-aurora-sample

Custom Lambda Function Not updating.

rajababu3 opened this issue · 4 comments

I uploaded Lambda to S3 like this

Lambda requires a specific format for code it executes - it must be inside a zip file with only the contents of the lambdaresolver directory, not a zip of the lambdaresolver directory.

When I update my lambda function index.js file with new table is is not fetched by cloudformation stack change set.

What will be the possible solution to this?

To clarify - you uploaded your own code to s3, updated the cloudformation document to point at that, and the code is not being pulled down? Was this the first time you had built with new code or a subsequent build?

Additionally, could you share the cloudformation definition for your Lambda function?

Thank you for the response.
Below is the cloudformation definition for Lambda function
AppSyncRDSLambda: Type: "AWS::Lambda::Function" Properties: Role: !GetAtt AppSyncRDSLambdaExecutionRole.Arn Code: S3Bucket: customlambda-ttl-works S3Key: Archive 2.zip Handler: index.handler MemorySize: 256 Runtime: "nodejs8.10" Timeout: "60" ReservedConcurrentExecutions: 100 Tags: - Key: AWSAppSyncCreatedResource Value: Fn::Sub: - "CloudFormation Stack ${StackName}" - StackName: !Ref "AWS::StackName" Environment: Variables: USERNAME: !Sub ${RDSUsername} PASSWORD: !Sub ${RDSPassword} ENDPOINT: !GetAtt AppSyncRDSCluster.Endpoint.Address DBNAME: !Sub ${RDSDBName} VpcConfig: SecurityGroupIds: - !GetAtt AppSyncRDSVPC.DefaultSecurityGroup SubnetIds: - !Ref AppSyncRDSSubnetPrivateA - !Ref AppSyncRDSSubnetPrivateB

It is invoking when I change S3Key Name whenever I make changes to it.

Just to make sure I understand - you're saying that the first time you execute the build, it pulls down the new code, but any subsequent update to the code in S3, the code isn't updated?

That's expected behavior - Cloudformation doesn't know the S3 file has been updated. You could work around that by having some kind of version suffix on the code, then updating the S3 key in the Cloudformation document. That will notify Cloudformation that there is a change to pull.

@jbailey2010 Thanks got to know.