I have created a pure python lambda function in python chalice app.py
like so:
@app.lambda_function('R53CloudformationResourceConflict')
def r53_cloudformation_resource_conflict(event, context):
logger.info(event)
logger.info(context)
Now the next part I am trying to do is call this lambda as a custom resource from a separate cloud formation template(cf.yml
) as so:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
LambdaFunctionName:
Type: String
Resources:
R53CloudformationResourceConflict:
Type: 'Custom::R53CloudformationResourceConflict'
Properties:
ServiceToken: !Join [ '', ['arn:aws:lambda:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':function:', !Ref LambdaFunctionName] ]
AppUrl: "some_app_url"
My file structure:
├── cf.yml
└── custom-lambda
├── app.py
└── requirements.txt
Currently python chalice prepends {{ app-name }}- {{ chalice-stage }}
to the pure lambda function name. So for this instance the final lambda name is custom-lambda-dev-R53CloudformationResourceConflict
.
Now the bit I am stuck on is dynamically knowing what my lambda function will be called(different stages, possibly app name change) and referencing that in the separate Cloud Formation stack(cf.yml) dynamically.
I have found https://chalice.readthedocs.io/en/stable/topics/configfile.html#lambda-specific-configuration this which might help but again this is fixed not dynamic.
Is there a relatively simply way to reference this pure lambda function created by python chalice in a separate Cloud Formation template in the same repo?