I have two lambda functions and one api gateway in SAM template. My template looks like,
Resources:
TempApi:
Type: AWS::Serverless::Api
Properties:
Auth:
DefaultAuthorizer: TempAuthorizer
Authorizer:
TempAuthorizer:
FunctionPayloadType: REQUEST
FunctionArn: !GetAtt TempAuthorizerFunction.Arn # This refers to Auth Function
AuthorizerPayloadFormatVersion: "2.0"
Identity:
Headers:
- Authorization
TempAuthorizerFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: "TempAuth"
Environment:
Variables:
API_RESOURCE_ARN: !Sub "arn::aws:execute-api:${AWS::Region}:${AWS:AccountId}:${TempApi}/*/POST/workwork/{eventName}" # This refers to api gateway
LastFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: "LastFunction"
# In my authorizer app.py I need to use API_RESOURCE_ARN
# authorizer/app.py
def temp_authorizer(event, context, logger, session):
response = {
"policyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Action": "execute-api:Invoke",
"Resource": ... # It will be passed by lambda function API_RESOURCE_ARN
"Effect": "Deny"
}]
},
"context": {}
}
How can I cut circular dependencies that I can use Api GateWay's Arn in TempAuthorizerFunction