Frank
Api
and a StaticSite
, where the frontend needs to know the API endpoint, and the API needs to know the frontend URL. Sample code here https://gist.github.com/fwang/db1e5697913c5533f8b95a4f04464870Frank
Adam Fanello
01/26/2022, 6:50 PM{Token}
in the output before it gets resolved. That only works for a one-way dependency, not a circular one.Derek Kershner
01/26/2022, 6:50 PMDerek Kershner
01/26/2022, 6:52 PMFrank
Frank
AWS::Cognito::UserPool
resource’s LambdaConfig
prop (for defining triggers) depends on `AWS:Lambda:Function`; and
• the AWS::Lambda::Function
resource’s Environment
prop depends on AWS::Cognito::UserPool
You’d have to use the SSM trick to get around this.Derek Kershner
01/26/2022, 7:10 PMAppClients
and using the right one (an autogenerated one that there is no control over) in a CustomResource
, so it is technically possible it could help, but your point is taken.Michael Robellard
01/26/2022, 8:09 PMMichael Robellard
01/26/2022, 8:12 PMFrank
Michael Robellard
01/26/2022, 8:22 PMimport boto3
import os
def normalize_name(name):
"""
Splits a name into its parts.
"""
parts = name.split('/')
return parts[-1]
class ParameterStore:
"""
Class to handle interactions with AWS Parameter Store.
"""
ssm = boto3.client('ssm')
@classmethod
def populate_cache(cls):
cls.parameter_cache = {}
response = cls.ssm.get_parameters_by_path(
Path='/all',
Recursive=True,
WithDecryption=True
)
for parameter in response['Parameters']:
cls.parameter_cache[normalize_name(parameter['Name'])] = parameter['Value']
response = cls.ssm.get_parameters_by_path(
Path='/' + os.environ['STAGE'],
Recursive=True,
WithDecryption=True
)
for parameter in response['Parameters']:
cls.parameter_cache[normalize_name(parameter['Name'])] = parameter['Value']
@classmethod
def get(cls, parameter_name):
if not hasattr(cls, 'parameter_cache'):
cls.populate_cache()
return cls.parameter_cache[parameter_name]
Adrián Mouly
01/26/2022, 10:23 PMAdrián Mouly
01/26/2022, 10:24 PM