cdk construct for importing a zipped Lex bot
Project description
cdk-lex-zip-import
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
Built Distribution
Hashes for cdk-lex-zip-import-0.0.39.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 170bed0afe6dd3ebbd37e01deb33dfad47d00f2e6e5db785a1e95430287ee06f |
|
MD5 | fd396824dd1f09d9312bd9807867f6d5 |
|
BLAKE2b-256 | 938e74ca677034ae3a7396c40fcc54fd814dd0ea0caf923f69afeb852b8b152b |
Hashes for cdk_lex_zip_import-0.0.39-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 847a59e10e1d4f0bdba22184f5ee08d28163a9e6f923c79de41898143c8753c8 |
|
MD5 | ca543e7c99e7765bffb08d423d1dc08b |
|
BLAKE2b-256 | a31053d579da457dc1a0f1c2c411e324b96f938afac3a8ffb573cf69881397a2 |