CDK Construct for creating Athena resources
Project description
CDK Athena WorkGroup
AWS CDK L3 construct for managing Athena WorkGroups and named queries.
Because I couldn't get @aws-cdk/aws-athena.CfnWorkGroup to work and @aws-cdk/custom-resources.AwsCustomResource has no support for tags.
Installation
This package has peer dependencies, which need to be installed along in the expected version.
For TypeScript/NodeJS, add these to your dependencies
in package.json
. For Python, add these to your requirements.txt
:
- cdk-ec2-key-pair
- aws-cdk-lib (^2.0.0)
- constructs (^10.0.0)
CDK compatibility
- Version 3.x is compatible with the CDK v2.
- Version 2.x is compatible with the CDK v1. There won't be regular updates for this.
Usage
const workgroup = new WorkGroup(this, 'WorkGroup', {
name: 'TheName', // required
desc: 'Some description',
publishCloudWatchMetricsEnabled: true,
enforceWorkGroupConfiguration: true,
requesterPaysEnabled: true,
bytesScannedCutoffPerQuery: 11000000,
resultConfiguration: {
outputLocation: `s3://some-bucket/prefix`,
encryptionConfiguration: {
encryptionOption: EncryptionOption.SSE_S3,
},
},
});
const query = new NamedQuery(this, 'a-query', {
name: 'A Test Query',
database: 'audit',
desc: 'This is the description',
queryString: `
SELECT
count(*) AS assumed,
split(useridentity.principalid, ':')[2] AS user,
resources[1].arn AS role
FROM cloudtrail_logs
WHERE
eventname='AssumeRole' AND
useridentity.principalid is NOT NULL AND
useridentity.principalid LIKE '%@%'
GROUP BY
split(useridentity.principalid,':')[2],
resources[1].arn
`,
workGroup: workgroup,
});
cdk.Tag.add(workgroup, 'HelloTag', 'ok');
new cdk.CfnOutput(this, 'WorkGroupArn', {
value: workgroup.arn,
});
new cdk.CfnOutput(this, 'WorkGroupName', {
value: workgroup.name,
});
new cdk.CfnOutput(this, 'QueryId', {
value: query.id,
});
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cdk-athena-3.0.0.tar.gz
(172.1 kB
view hashes)
Built Distribution
cdk_athena-3.0.0-py3-none-any.whl
(170.6 kB
view hashes)
Close
Hashes for cdk_athena-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 736be628e66fcfea9b923ed35cbf16fb9808057ac551169a98a104e7ee0731f5 |
|
MD5 | cf8547aca0a8a573e63e079277b9e9a9 |
|
BLAKE2b-256 | eb454a72fc3ad24506a93a4b464679ac15149eed985b1cb29253b6ecf8ea777d |