Can't create Lambda code hook for Lex's TestBotAlias with CloudFormation

1

My team is building a Lex Bot backed by AWS Lambda as a fulfillment code hook. We're using CloudFormation to deploy the stack.

We're facing an issue where with each deployment introducing changes to the bot, the association between the Lambda and the TestBotAlias gets removed.

We've tried to build an AWS::Lex::BotAlias, but it doesn't work because CloudFormation tries to create a second alias with the same name. Moreover, references to the DRAFT version of the bot are not possible because AWS::Lex::BotVersion allows us only to use numerical values.

Is there a recommended way to associate the Lex bot with Lambda for tests so that it doesn't get removed every time we deploy a stack?

2개 답변
0

Hello!

With the way that the CloudFormation workflow is set up, there is currently no mechanism of modifying the TestBotAlias within a CFN template. In the meantime a possible solution you can use is to create a new BotVersion when you are ready to test your bot and associate an AWS::Lex::BotAlias resource with templated bot version.

If there are any other questions please feel free to reach out again!

KevinC
답변함 2년 전
  • This is really inconvenient.. Is there a way to modify the TestBotAlias after deployment?

0

I was finally able to get this working (in AWS CDK)

While defining the lex bot:

test_bot_alias_settings = (
    lex.CfnBot.TestBotAliasSettingsProperty(
        bot_alias_locale_settings=[
            lex.CfnBot.BotAliasLocaleSettingsItemProperty(
                locale_id="en_US",
                bot_alias_locale_setting=lex.CfnBot.BotAliasLocaleSettingsProperty(
                    enabled=True,
                    code_hook_specification=lex.CfnBot.CodeHookSpecificationProperty(
                        lambda_code_hook=lex.CfnBot.LambdaCodeHookProperty(
                            code_hook_interface_version="1.0",
                            lambda_arn=self.my_lex_lambda.function_arn,
                        )
                    ),
                ),
            )
        ],
    ),
)

wcheek
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠