Skip to content

Commit 3595157

Browse files
committed
Adds Database resource
1 parent ce22a4b commit 3595157

21 files changed

+12128
-0
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Distribution / packaging
2+
build/
3+
dist/
4+
5+
# Unit test / coverage reports
6+
.cache
7+
.hypothesis/
8+
.pytest_cache/
9+
10+
# RPDK logs
11+
rpdk.log*
12+
13+
# Node.js
14+
node_modules/
15+
coverage/
16+
17+
# contains credentials
18+
sam-tests/

Snowflake-Database-Database/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optional = true
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"artifact_type": "RESOURCE",
3+
"typeName": "Snowflake::Database::Database",
4+
"language": "typescript",
5+
"runtime": "nodejs12.x",
6+
"entrypoint": "dist/Snowflake-Database-Database/src/handlers.entrypoint",
7+
"testEntrypoint": "dist/Snowflake-Database-Database/src/handlers.testEntrypoint",
8+
"settings": {
9+
"version": false,
10+
"subparser_name": null,
11+
"verbose": 0,
12+
"force": false,
13+
"type_name": null,
14+
"artifact_type": null,
15+
"endpoint_url": null,
16+
"region": null,
17+
"target_schemas": [],
18+
"useDocker": true,
19+
"protocolVersion": "2.0.0"
20+
}
21+
}

Snowflake-Database-Database/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Snowflake::Database::Database
2+
3+
Congratulations on starting development! Next steps:
4+
5+
1. Write the JSON schema describing your resource, [snowflake-database-database.json](./snowflake-database-database.json)
6+
2. Implement your resource handlers in [handlers.ts](./snowflake-database-database/handlers.ts)
7+
8+
> Don't modify [models.ts](./snowflake-database-database/models.ts) by hand, any modifications will be overwritten when the `generate` or `package` commands are run.
9+
10+
Implement CloudFormation resource here. Each function must always return a ProgressEvent.
11+
12+
```typescript
13+
const progress = ProgressEvent.builder<ProgressEvent<ResourceModel>>()
14+
15+
// Required
16+
// Must be one of OperationStatus.InProgress, OperationStatus.Failed, OperationStatus.Success
17+
.status(OperationStatus.InProgress)
18+
// Required on SUCCESS (except for LIST where resourceModels is required)
19+
// The current resource model after the operation; instance of ResourceModel class
20+
.resourceModel(model)
21+
.resourceModels(null)
22+
// Required on FAILED
23+
// Customer-facing message, displayed in e.g. CloudFormation stack events
24+
.message('')
25+
// Required on FAILED a HandlerErrorCode
26+
.errorCode(HandlerErrorCode.InternalFailure)
27+
// Optional
28+
// Use to store any state between re-invocation via IN_PROGRESS
29+
.callbackContext({})
30+
// Required on IN_PROGRESS
31+
// The number of seconds to delay before re-invocation
32+
.callbackDelaySeconds(0)
33+
34+
.build()
35+
```
36+
37+
While importing the [@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin) library, failures can be passed back to CloudFormation by either raising an exception from `exceptions`, or setting the ProgressEvent's `status` to `OperationStatus.Failed` and `errorCode` to one of `HandlerErrorCode`. There is a static helper function, `ProgressEvent.failed`, for this common case.
38+
39+
Keep in mind, during runtime all logs will be delivered to CloudWatch if you use the `log()` method from `LoggerProxy` class.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
AWSTemplateFormatVersion: '2010-09-09'
3+
4+
Description: |
5+
The following CloudFormation Snowflake resource types allow the creation and configuration of
6+
a Database
7+
8+
Resources:
9+
NewDatabase:
10+
Type: Snowflake::Database::Database
11+
Properties:
12+
Name: ExampleDatabase
13+
DataRetentionTimeInDays: 1
14+
MaxDataExtensionTimeInDays: 1
15+
DefaultDdlCollation: "en-ci"
16+
Comment: "This is a comment""
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Snowflake::Database::Database
2+
3+
An example resource schema demonstrating some basic constructs and validation rules.
4+
5+
## Syntax
6+
7+
To declare this entity in your AWS CloudFormation template, use the following syntax:
8+
9+
### JSON
10+
11+
<pre>
12+
{
13+
"Type" : "Snowflake::Database::Database",
14+
"Properties" : {
15+
"<a href="#name" title="Name">Name</a>" : <i>String</i>,
16+
"<a href="#dataretentiontimeindays" title="DataRetentionTimeInDays">DataRetentionTimeInDays</a>" : <i>Integer</i>,
17+
"<a href="#maxdataextensiontimeindays" title="MaxDataExtensionTimeInDays">MaxDataExtensionTimeInDays</a>" : <i>Integer</i>,
18+
"<a href="#defaultddlcollation" title="DefaultDdlCollation">DefaultDdlCollation</a>" : <i>String</i>,
19+
"<a href="#comment" title="Comment">Comment</a>" : <i>String</i>,
20+
}
21+
}
22+
</pre>
23+
24+
### YAML
25+
26+
<pre>
27+
Type: Snowflake::Database::Database
28+
Properties:
29+
<a href="#name" title="Name">Name</a>: <i>String</i>
30+
<a href="#dataretentiontimeindays" title="DataRetentionTimeInDays">DataRetentionTimeInDays</a>: <i>Integer</i>
31+
<a href="#maxdataextensiontimeindays" title="MaxDataExtensionTimeInDays">MaxDataExtensionTimeInDays</a>: <i>Integer</i>
32+
<a href="#defaultddlcollation" title="DefaultDdlCollation">DefaultDdlCollation</a>: <i>String</i>
33+
<a href="#comment" title="Comment">Comment</a>: <i>String</i>
34+
</pre>
35+
36+
## Properties
37+
38+
#### Name
39+
40+
Specifies the identifier for the database; must be unique for your account.
41+
42+
_Required_: Yes
43+
44+
_Type_: String
45+
46+
_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)
47+
48+
#### DataRetentionTimeInDays
49+
50+
Specifies the number of days for which Time Travel actions can be performed on the database.
51+
52+
_Required_: No
53+
54+
_Type_: Integer
55+
56+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
57+
58+
#### MaxDataExtensionTimeInDays
59+
60+
The maximum number of days for which Snowflake can extend the data retention period for tables in the database.
61+
62+
_Required_: No
63+
64+
_Type_: Integer
65+
66+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
67+
68+
#### DefaultDdlCollation
69+
70+
Specifies a default collation specification for all schemas and tables added to the database
71+
72+
_Required_: No
73+
74+
_Type_: String
75+
76+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
77+
78+
#### Comment
79+
80+
Specifies a comment for the database.
81+
82+
_Required_: No
83+
84+
_Type_: String
85+
86+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
87+
88+
## Return Values
89+
90+
### Ref
91+
92+
When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the Name.
93+
94+
### Fn::GetAtt
95+
96+
The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
97+
98+
For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html).
99+
100+
#### Database
101+
102+
Returns the <code>Database</code> value.
103+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Snowflake::Database::Database Database
2+
3+
## Syntax
4+
5+
To declare this entity in your AWS CloudFormation template, use the following syntax:
6+
7+
### JSON
8+
9+
<pre>
10+
{
11+
"<a href="#name" title="Name">Name</a>" : <i>String</i>,
12+
"<a href="#dataretentiontimeindays" title="DataRetentionTimeInDays">DataRetentionTimeInDays</a>" : <i>Integer</i>,
13+
"<a href="#maxdataextensiontimeindays" title="MaxDataExtensionTimeInDays">MaxDataExtensionTimeInDays</a>" : <i>Integer</i>,
14+
"<a href="#defaultddlcollation" title="DefaultDdlCollation">DefaultDdlCollation</a>" : <i>String</i>,
15+
"<a href="#comment" title="Comment">Comment</a>" : <i>String</i>
16+
}
17+
</pre>
18+
19+
### YAML
20+
21+
<pre>
22+
<a href="#name" title="Name">Name</a>: <i>String</i>
23+
<a href="#dataretentiontimeindays" title="DataRetentionTimeInDays">DataRetentionTimeInDays</a>: <i>Integer</i>
24+
<a href="#maxdataextensiontimeindays" title="MaxDataExtensionTimeInDays">MaxDataExtensionTimeInDays</a>: <i>Integer</i>
25+
<a href="#defaultddlcollation" title="DefaultDdlCollation">DefaultDdlCollation</a>: <i>String</i>
26+
<a href="#comment" title="Comment">Comment</a>: <i>String</i>
27+
</pre>
28+
29+
## Properties
30+
31+
#### Name
32+
33+
Specifies the identifier for the database; must be unique for your account.
34+
35+
_Required_: No
36+
37+
_Type_: String
38+
39+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
40+
41+
#### DataRetentionTimeInDays
42+
43+
Specifies the number of days for which Time Travel actions can be performed on the database.
44+
45+
_Required_: No
46+
47+
_Type_: Integer
48+
49+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
50+
51+
#### MaxDataExtensionTimeInDays
52+
53+
The maximum number of days for which Snowflake can extend the data retention period for tables in the database.
54+
55+
_Required_: No
56+
57+
_Type_: Integer
58+
59+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
60+
61+
#### DefaultDdlCollation
62+
63+
Specifies a default collation specification for all schemas and tables added to the database
64+
65+
_Required_: No
66+
67+
_Type_: String
68+
69+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
70+
71+
#### Comment
72+
73+
Specifies a comment for the database.
74+
75+
_Required_: No
76+
77+
_Type_: String
78+
79+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
80+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"TPSCode": "...",
3+
"Title": "...",
4+
"CoverSheetIncluded": "...",
5+
"DueDate": "...",
6+
"ApprovalDate": "...",
7+
"Memo": "...",
8+
"SecondCopyOfMemo": "...",
9+
"TestCode": "...",
10+
"Authors": "...",
11+
"Tags": "..."
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"TPSCode": "...",
3+
"Title": "...",
4+
"CoverSheetIncluded": "...",
5+
"DueDate": "...",
6+
"ApprovalDate": "...",
7+
"Memo": "...",
8+
"SecondCopyOfMemo": "...",
9+
"TestCode": "...",
10+
"Authors": "...",
11+
"Tags": "..."
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"TPSCode": "...",
3+
"Title": "...",
4+
"CoverSheetIncluded": "...",
5+
"DueDate": "...",
6+
"ApprovalDate": "...",
7+
"Memo": "...",
8+
"SecondCopyOfMemo": "...",
9+
"TestCode": "...",
10+
"Authors": "...",
11+
"Tags": "..."
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
transform: {
5+
'^.+\\.ts?$': 'ts-jest',
6+
},
7+
transformIgnorePatterns: ['<rootDir>/node_modules/'],
8+
};
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"CREATE": {
3+
"/Name": "SAMDatabase",
4+
"/DataRetentionTimeInDays": 1,
5+
"/MaxDataExtensionTimeInDays": 2,
6+
"/DefaultDdlCollation": "en-ci",
7+
"/Comment": "This is a comment"
8+
},
9+
"UPDATE": {
10+
"/Name": "UpdatedSAMDb",
11+
"/DataRetentionTimeInDays": 1,
12+
"/MaxDataExtensionTimeInDays": 4,
13+
"/DefaultDdlCollation": "fr-ai",
14+
"/Comment": "Updated comment"
15+
}
16+
}

0 commit comments

Comments
 (0)