Describe the bug
Automatically generated IAM Role Names for @function directive are not unique enough.
Will result in AWS::IAM::Role already exists in (other) stack error
To Reproduce
Steps to reproduce the behavior:
long-service-name-functionsdo-something and get-somethinglong-service-name-functions-prod-do-something and long-service-name-functions-prod-get-something@function directivetype Query {
getSomething(email: String): String
@function(name: "long-service-name-functions-prod-get-something")
}
type Mutation {
doSomething(email: String): String
@function(name: "long-service-name-functions-prod-do-something")
}
LongServiceNameFunctionsPr-xxxxxxxxxxxxxxxxxxxxxxxxxx-production for both functions. And will result in an AWS::IAM::Role already exists in (other) stack error Expected behavior
Does anyone have any workarounds for this in the meantime, manual steps will do?
@danshirley1 We got the issue recently too. These kind of cloudformation limitations are becoming a huge blocker for Amplify in a greater extent. @SwaySway Is their any workaround?
@danshirley1 @babu-upcomer the +/- first 27 characters of the lambda function name is used for the IAM Role Name.
The only workaround is to use shorter Lambda function names (more likely that the first 27 characters are unique)
Don't know whether this is a limitation of Cloudformation or Amplify.
@SwaySway Adding a hash based on the full string (for example md5) as a prefix to the simplifyName function (https://github.com/aws-amplify/amplify-cli/blob/master/packages/graphql-transformer-common/src/util.ts#L16), do you think this can work?
@daannijkamp Yea it's a cloudformation (related to iam) limit that is 64 characters on the iam role name which is created for the lambda function.
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html
Which is comprised of the following
functionName-API_ID-HashOne option would be to remove the api id and that alone could be unique with the function name and the hash.
Closing this as the pr #3030 for this has been merged.