Skip to main content

cdk construct for importing a zipped Lex bot

Project description

cdk-lex-zip-import

Experimental

An AWS Cloud Development Kit (AWS CDK) construct library that allows you to upload and deploy a Zipped Lex Bot. Once imported, this Bot can be managed within the Amazon Lex Console.

Usage

To add to your AWS CDK package.json file:

yarn add cdk-lex-zip-import

Within your AWS CDK:

Import Lex Bot

const bot = new lexupload.ImportBot(this, 'lexBot', {
  sourceDirectory: './resources/LexBot',
  lexRoleArn: lexRole.roleArn,
});

The sourceDirecotry must include a file named LexBot.zip. All files in that directory will be uploaded, but only a file named LexBot.zip will be imported to Lex as a Bot.

The lexRoleArn refers to the roleArn of an IAM Role. For example:

const lexRole = new iam.Role(this, 'lexRole', {
  assumedBy: new iam.ServicePrincipal('lex.amazonaws.com'),
  inlinePolicies: {
    ['lexPolicy']: new iam.PolicyDocument({
      statements: [
        new iam.PolicyStatement({
          resources: ['*'],
          actions: ['polly:SynthesizeSpeech', 'comprehend:DetectSentiment'],
        }),
      ],
    }),
  },
});

Adding a Resource Policy

bot.addResourcePolicy(resourceArn, policy);

addResourcePolicy requires two properties: the resourceArn of the Lex Bot, and a policy to be applied. This policy will be applied to the alias associated with the Bot.

Resource ARN Example:

const resourceArn = `arn:aws:lex:${this.region}:${this.account}:bot-alias/${bot.botId}/${bot.botAliasId}`;

Policy Example:

const policy = {
  Version: '2012-10-17',
  Statement: [
    {
      Sid: 'AllowChimePstnAudioUseBot',
      Effect: 'Allow',
      Principal: { Service: 'voiceconnector.chime.amazonaws.com' },
      Action: 'lex:StartConversation',
      Resource: resourceArn,
      Condition: {
        StringEquals: { 'AWS:SourceAccount': `${this.account}` },
        ArnEquals: {
          'AWS:SourceArn': `arn:aws:voiceconnector:us-east-1:${this.account}:*`,
        },
      },
    },
  ],
};

Not Supported Yet

This is a work in progress.

Features that are not supported yet:

  • Non-Draft Versions
  • Updates to created resources

Contributing

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-lex-zip-import-0.0.90.tar.gz (432.8 kB view details)

Uploaded Source

Built Distribution

cdk_lex_zip_import-0.0.90-py3-none-any.whl (431.1 kB view details)

Uploaded Python 3

File details

Details for the file cdk-lex-zip-import-0.0.90.tar.gz.

File metadata

  • Download URL: cdk-lex-zip-import-0.0.90.tar.gz
  • Upload date:
  • Size: 432.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for cdk-lex-zip-import-0.0.90.tar.gz
Algorithm Hash digest
SHA256 0ce0e30fa940bbdc447a580bfb0b38e25aad8507e5e7558d3646cd69ffadfbd1
MD5 4effc97cf5f19aba16d4899afc45f6bc
BLAKE2b-256 d288eb4d69f33748538b4e1fb47633fa5b57779984dc8ce9e945621e82edf6f0

See more details on using hashes here.

File details

Details for the file cdk_lex_zip_import-0.0.90-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk_lex_zip_import-0.0.90-py3-none-any.whl
Algorithm Hash digest
SHA256 485b631febe94437b395a2b3de42408e40cca61e090411060e3ed744c13b2643
MD5 5048f0feaa7127805a010aacee161df6
BLAKE2b-256 74d1743e88b28e0ef64ddf4f455b4a2e6d51b0beb19e304d2d6944218f4bf73e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page