I’ve submitted a bug report:
opened 02:37AM - 16 Jan 22 UTC
### Are you certain it's a bug?
- [X] Yes, it looks like a bug
### Is the issu… e caused by a plugin?
- [X] It is not a plugin issue
### Are you using the latest version?
- [X] Yes, I'm using the latest version
### Is there an existing issue for this?
- [X] I have searched existing issues, it hasn't been reported yet
### Issue description
I'm not using any plugins.
```
RetrieveAllSubscribersLambdaPermissionApiGateway:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName: { "Fn::GetAtt": [ RetrieveAllSubscribersLambdaFunction, Arn ] }
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
SourceArn:
Fn::Join:
- ""
- - "helloworld"
- "*"
```
The output is the following:
```
An error occurred: RetrieveAllSubscribersLambdaPermissionApiGateway - 1 validation error detected: Value 'helloworld*:execute-api:us-west-2:185871347164:a53ihjk9/*/*' at 'sourceArn' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-])+:([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.*) (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: 0646f60d41f; Proxy: null).
```
My question is, how is it possible for the random data in the error to still show up in the `SourceArn` if I only joined together the two strings above?
It seems like the join function in this case is making some assumption on what else should be injected in the value? Ideally, I just wanted to interpolate the logical id from a raw `!Ref ApiGatewayRestApi`
### Service configuration (serverless.yml) content
```yaml
Will post if necessary
```
### Command name and used flags
sls deploy
### Command output
```shell
See above
```
### Environment information
```shell
Operating System: darwin
Node Version: 17.3.0
Framework Version: 2.71.0 (local)
Plugin Version: 5.5.3
SDK Version: 4.3.0
Components Version: 3.18.1
```
Unsure if a bug. I’m trying to create a lambda permission, but I want a dynamic ARN to be populated.
RetrieveAllSubscribersLambdaPermissionApiGateway:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName: { "Fn::GetAtt": [ RetrieveAllSubscribersLambdaFunction, Arn ] }
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
SourceArn: ${self:custom.ApiGatewayMetadata.uniqueId}
This fails consistently by saying the resource is not a string, etc. I’ve tried with Join (see above bug report) and standard interpolation, to no avail.
I’ve even tried really weird stuff:
custom:
SubscribedUsersTable:
name: !Ref UsersSubscriptionTable
arn: !GetAtt UsersSubscriptionTable.Arn
ApiGatewayMetadata:
test: !GetAtt ApiGatewayRestApi.RootResourceId
logicalId: ${self:custom.ApiGatewayMetadata.test, 'none'}
uniqueId: 'arn:aws:execute-api:us-west-2:1234/${self:custom.ApiGatewayMetadata.logicalId}/*/GET/users'
bundle:
linting: false