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.
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-2.1.1.tar.gz
(103.2 kB
view hashes)
Built Distribution
cdk_athena-2.1.1-py3-none-any.whl
(101.6 kB
view hashes)
Close
Hashes for cdk_athena-2.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a075fde488ee2b6ed72227a0dc971f7e5480f78e7dcf76bbf80582448fb6569 |
|
MD5 | 535dcba39f262f8ab86e399b00ea563a |
|
BLAKE2b-256 | ec5bd76beb75079345ccc28e5512901eec59f248de318a2a1fa55007d7ba017e |