· 5 years ago · Feb 06, 2020, 11:42 AM
1{
2 "AWSTemplateFormatVersion": "2010-09-09",
3
4 "Description": "Provisions the region-specific cloud storage resources",
5
6 "Parameters": {
7 "S3InventoryCleanUpHandlerArn": {
8 "Description": "The ARN of the S3InventoryCleanUpHandler lambda function.",
9 "Type": "String"
10 },
11 "DataBucketRootName": {
12 "Description": "Root name for Data bucket.",
13 "Type": "String"
14 },
15 "AthenaDBName": {
16 "Description": "Athena database name.",
17 "Type": "String"
18 },
19 "AthenaTablePrefix": {
20 "Description": "Prefix of Athena table name for inventory data and inventory summary tables.",
21 "Type": "String"
22 },
23 "S3InventoryLocationPrefix": {
24 "Description": "S3 path prefix to store inventory summary results",
25 "Type": "String"
26 },
27 "S3InventoryName": {
28 "Description": "S3 inventory name.",
29 "Type": "String"
30 },
31 "TemplateMD5": {
32 "Description": "Unique part of template to support updates of Athena Named Query",
33 "Type": "String"
34 }
35 },
36
37 "Resources" : {
38 "S3InventoryCleanUpSNS": {
39 "Type" : "AWS::SNS::Topic",
40 "Properties" : {
41 "DisplayName" : "S3 inventory clean up SNS",
42 "Subscription" : [
43 {
44 "Endpoint" : { "Ref" : "S3InventoryCleanUpHandlerArn" },
45 "Protocol" : "lambda"
46 }
47 ],
48 "TopicName" : { "Fn::Join" : ["-", [{"Ref" : "AWS::StackName"}, "S3InventoryCleanUpSNS"]]}
49 }
50 },
51 "S3InventoryCreateTableQuery": {
52 "Type": "AWS::Athena::NamedQuery",
53 "Properties": {
54 "Database": { "Ref" : "AthenaDBName" },
55 "Description": "A query that creates the inventory athena table",
56 "Name": {
57 "Fn::Join": [
58 "_",
59 [
60 "S3InventoryCreateTableQuery",
61 {
62 "Ref": "TemplateMD5"
63 }
64 ]
65 ]
66 },
67 "QueryString": {"Fn::Join" : [ " ", [
68 "CREATE EXTERNAL TABLE IF NOT EXISTS",
69 { "Fn::Join" : [ "", [ { "Ref" : "AthenaTablePrefix" }, "_", "s3_inventory", "_", "REGION_NAME" ]]},
70 "(Bucket STRING,",
71 "CustomerId STRING,",
72 "EnvType STRING,",
73 "Classification STRING,",
74 "Key STRING,",
75 "VersionId STRING,",
76 "IsLatest STRING,",
77 "IsDeleteMarker STRING,",
78 "Bytes BIGINT",
79 ") ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'",
80 "WITH SERDEPROPERTIES (",
81 "\"input.regex\"",
82 "=",
83 "\"^\\\"([^ ]*)\\\"\\,\\\"([^ \\\/]*)\\\/([^ \\\/]*)\\\/([^ \\\/]*)([^ ]*)\\\"\\,\\\"([^ ]*)\\\",\\\"([^ ]*)\\\",\\\"([^ ]*)\\\",\\\"([^ ]*)\\\"$\"",
84 ") LOCATION",
85 { "Fn::Join" : [ "", [ "'s3://", { "Ref" : "DataBucketRootName" }, "-", "DATA_BUCKET_REGION", "/", { "Ref" : "S3InventoryLocationPrefix" }, "/", { "Ref" : "DataBucketRootName" }, "-", "DATA_BUCKET_REGION", "/", { "Ref" : "S3InventoryName" }, "/data/'" ]]}
86 ] ]}
87 }
88 }
89 },
90 "Outputs": {
91 "S3InventoryCleanUpSNS" : {
92 "Value" : { "Ref" : "S3InventoryCleanUpSNS"},
93 "Description" : "The name of the s3 inventory clean up function SNS Topic."
94 }
95 }
96}