rhythmic-country-29988
04/30/2020, 8:11 AMimport * as aws from '@pulumi/aws';
import * as pulumi from '@pulumi/pulumi';
import { v4 as uuid } from 'uuid';
import { CognitoUserPoolTriggerEvent } from 'aws-lambda';
const name = 'mylambda';
const partitionRole = new aws.iam.Role(
`${name}-lambda-role`, {
assumeRolePolicy: JSON.stringify({
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
},
"Effect": "Allow",
"Sid": "",
},
],
})
},
);
const attachment = new aws.iam.RolePolicyAttachment(
`${name}-lambda-role-attachment`, {
role: partitionRole,
policyArn: aws.iam.ManagedPolicies.AWSLambdaFullAccess,
},
{ dependsOn: [ partitionRole ] },
);
const preTokenLambda = new aws.lambda.CallbackFunction<CognitoUserPoolTriggerEvent, CognitoUserPoolTriggerEvent>(
name, {
name: `${name}-lambda-${uuid()}`,
description: "lambda.",
role: partitionRole,
runtime: aws.lambda.NodeJS12dXRuntime,
memorySize: 128,
timeout: 30,
reservedConcurrentExecutions: 50,
callback: async (event) => {
event.response.claimsOverrideDetails = {
claimsToAddOrOverride: {
role: 'member',
bla: 'yes',
},
};
return event;
},
},
{ dependsOn: [ partitionRole, attachment ] },
);
I am forcing the lambda to recreate including a uuid in its name. It uploads it correctly but then I consistently get a function already exist
error
+ aws:lambda:Function pool creating error: Error creating Lambda function: ResourceConflictException: Function already exist: pool-lambda-80a6da40-c917-41c9-90d8-7cef62a40dcc
any ideas?{
RespMetadata: {
StatusCode: 409,
RequestID: "4571dacb-8e3b-42e1-bcc3-3ee762eb560c"
},
Message_: "Function already exist: pool-lambda-80a6da40-c917-41c9-90d8-7cef62a40dcc",
Type: "User"
}
409 response is
ResourceConflictException
The resource already exists, or another operation is in progress.
HTTP Status Code: 409
white-balloon-205
deleteBeforeReplace.
rhythmic-country-29988
05/04/2020, 8:06 AM