By using AWS re:Post, you agree to the Terms of Use

AWS::Lex::BotVersion does not create other versions than 1


My team is building a Lex bot, and we're using CloudFormation + CodePipeline to deploy our stack.

We've noticed that creating an AWS::Lex::BotVersion successfully creates the first bot version. However, introducing subsequent changes to the bot does not trigger new version updates. We're effectively referencing the first version of the bot every time. Below is the definition of the version and the associated alias that we use:

    Type: AWS::Lex::BotVersion
      BotId: !Ref ReschedulingBot
        - LocaleId: en_US
            SourceBotVersion: DRAFT

    Type: AWS::Lex::BotAlias
      BotId: !Ref ReschedulingBot
      BotAliasName: Live
      BotVersion: !GetAtt ReschedulingBotVersion.BotVersion

So far, we're working around it by having a Lambda function which calls the update_bot_alias AWS API as the final step of the run of the pipeline. It correctly associates the alias with the newest bot version.

How else could we approach the upgrade of bot versions, so that we could eventually retire the Lambda mentioned above?

1 Answer
Accepted Answer


Thank you for reaching out regarding the Lex Cloud Formation feature.

The AWS::Lex::BotVersion resource was designed to be treated as an immutable resource. Think of it as a solution if you want to codify a working version that will be saved for the future. An example would be a production version (with corresponding alias) and a pre-production version. Thus this resource is not as useful if there is a need to test or develop while wanting to publish a new version every iteration.

However there is a mechanism you can use to accomplish creating a new version with every CFN iteration. You can modify the CloudFormation primary identifier for the AWS::Lex::BotVersion resource when you want to update your BotVersion. For your example it would be changing the PrimaryID ReschedulingBotVersion to ReschedulingBotVersionTwo. This will effectively delete corresponding BotVersion #1 and create a new BotVersion #2. In the event you want to keep existing bot versions, you would need to create a separate BotVersion resource to avoid deletion.

If there's any more questions please feel free to comment again and we'll try to address any issues.

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions