# cdk-lex-zip-import
![Experimental](https://img.shields.io/badge/experimental-important.svg?style=for-the-badge)
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
```python
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:
```python
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
```python
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:
```python
const resourceArn = `arn:aws:lex:${this.region}:${this.account}:bot-alias/${bot.botId}/${bot.botAliasId}`;
```
#### Policy Example:
```python
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](CONTRIBUTING.md) for more information.
## License
This project is licensed under the Apache-2.0 License.
Raw data
{
"_id": null,
"home_page": "https://github.com/schuettc/cdk-lex-zip-import.git",
"name": "cdk-lex-zip-import",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Court Schuett<schuettc@amazon.com>",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/d2/88/eb4d69f33748538b4e1fb47633fa5b57779984dc8ce9e945621e82edf6f0/cdk-lex-zip-import-0.0.90.tar.gz",
"platform": null,
"description": "# cdk-lex-zip-import\n\n![Experimental](https://img.shields.io/badge/experimental-important.svg?style=for-the-badge)\n\nAn 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.\n\n## Usage\n\nTo add to your AWS CDK package.json file:\n\n```\nyarn add cdk-lex-zip-import\n```\n\nWithin your AWS CDK:\n\n### Import Lex Bot\n\n```python\nconst bot = new lexupload.ImportBot(this, 'lexBot', {\n sourceDirectory: './resources/LexBot',\n lexRoleArn: lexRole.roleArn,\n});\n```\n\nThe `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.\n\nThe `lexRoleArn` refers to the roleArn of an IAM Role. For example:\n\n```python\nconst lexRole = new iam.Role(this, 'lexRole', {\n assumedBy: new iam.ServicePrincipal('lex.amazonaws.com'),\n inlinePolicies: {\n ['lexPolicy']: new iam.PolicyDocument({\n statements: [\n new iam.PolicyStatement({\n resources: ['*'],\n actions: ['polly:SynthesizeSpeech', 'comprehend:DetectSentiment'],\n }),\n ],\n }),\n },\n});\n```\n\n### Adding a Resource Policy\n\n```python\nbot.addResourcePolicy(resourceArn, policy);\n```\n\n`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.\n\n#### Resource ARN Example:\n\n```python\nconst resourceArn = `arn:aws:lex:${this.region}:${this.account}:bot-alias/${bot.botId}/${bot.botAliasId}`;\n```\n\n#### Policy Example:\n\n```python\nconst policy = {\n Version: '2012-10-17',\n Statement: [\n {\n Sid: 'AllowChimePstnAudioUseBot',\n Effect: 'Allow',\n Principal: { Service: 'voiceconnector.chime.amazonaws.com' },\n Action: 'lex:StartConversation',\n Resource: resourceArn,\n Condition: {\n StringEquals: { 'AWS:SourceAccount': `${this.account}` },\n ArnEquals: {\n 'AWS:SourceArn': `arn:aws:voiceconnector:us-east-1:${this.account}:*`,\n },\n },\n },\n ],\n};\n```\n\n## Not Supported Yet\n\nThis is a work in progress.\n\nFeatures that are not supported yet:\n\n* [ ] Non-Draft Versions\n* [ ] Updates to created resources\n\n## Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for more information.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "cdk construct for importing a zipped Lex bot",
"version": "0.0.90",
"project_urls": {
"Homepage": "https://github.com/schuettc/cdk-lex-zip-import.git",
"Source": "https://github.com/schuettc/cdk-lex-zip-import.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "74d1743e88b28e0ef64ddf4f455b4a2e6d51b0beb19e304d2d6944218f4bf73e",
"md5": "5048f0feaa7127805a010aacee161df6",
"sha256": "485b631febe94437b395a2b3de42408e40cca61e090411060e3ed744c13b2643"
},
"downloads": -1,
"filename": "cdk_lex_zip_import-0.0.90-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5048f0feaa7127805a010aacee161df6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 431063,
"upload_time": "2024-01-20T23:36:22",
"upload_time_iso_8601": "2024-01-20T23:36:22.425943Z",
"url": "https://files.pythonhosted.org/packages/74/d1/743e88b28e0ef64ddf4f455b4a2e6d51b0beb19e304d2d6944218f4bf73e/cdk_lex_zip_import-0.0.90-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d288eb4d69f33748538b4e1fb47633fa5b57779984dc8ce9e945621e82edf6f0",
"md5": "4effc97cf5f19aba16d4899afc45f6bc",
"sha256": "0ce0e30fa940bbdc447a580bfb0b38e25aad8507e5e7558d3646cd69ffadfbd1"
},
"downloads": -1,
"filename": "cdk-lex-zip-import-0.0.90.tar.gz",
"has_sig": false,
"md5_digest": "4effc97cf5f19aba16d4899afc45f6bc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 432777,
"upload_time": "2024-01-20T23:36:25",
"upload_time_iso_8601": "2024-01-20T23:36:25.007416Z",
"url": "https://files.pythonhosted.org/packages/d2/88/eb4d69f33748538b4e1fb47633fa5b57779984dc8ce9e945621e82edf6f0/cdk-lex-zip-import-0.0.90.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-20 23:36:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "schuettc",
"github_project": "cdk-lex-zip-import",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cdk-lex-zip-import"
}