-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Time::Offset resource
- Loading branch information
Showing
32 changed files
with
1,206 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# macOS | ||
.DS_Store | ||
._* | ||
|
||
# our logs | ||
rpdk.log* | ||
|
||
#compiled file | ||
bin/ | ||
|
||
#vender | ||
vender/ | ||
|
||
# contains credentials | ||
sam-tests/ | ||
.hypothesis/ | ||
/awscommunity-time-offset.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"artifact_type": "RESOURCE", | ||
"typeName": "AwsCommunity::Time::Offset", | ||
"language": "go", | ||
"runtime": "go1.x", | ||
"entrypoint": "handler", | ||
"testEntrypoint": "handler", | ||
"settings": { | ||
"version": false, | ||
"subparser_name": null, | ||
"verbose": 0, | ||
"force": false, | ||
"type_name": null, | ||
"artifact_type": null, | ||
"endpoint_url": null, | ||
"region": null, | ||
"target_schemas": [], | ||
"import_path": "github.com/aws-cloudformation/awscommunity-registry-extensions/resources/Time_Offset", | ||
"protocolVersion": "2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: build test clean | ||
|
||
build: | ||
make -f makebuild # this runs build steps required by the cfn cli | ||
|
||
test: | ||
cfn generate | ||
env GOOS=linux go build -ldflags="-s -w" -o bin/handler cmd/main.go | ||
|
||
clean: | ||
rm -rf bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# AwsCommunity::Time::Offset | ||
|
||
Creates a time based resource with an offset. | ||
|
||
## Example | ||
|
||
```yaml | ||
Resources: | ||
StarTime: | ||
Type: AwsCommunity::Time::Offset | ||
Properties: | ||
OffsetHours: 1 | ||
EndTime: | ||
Type: AwsCommunity::Time::Offset | ||
Properties: | ||
OffsetYears: 5 | ||
DailyNotice: | ||
Type: AWS::Pinpoint::Campaign | ||
Properties: | ||
... | ||
Schedule: | ||
EndTime: !GetAtt EndTime.Utc | ||
Frequency: "DAILY" | ||
IsLocalTime: true | ||
StartTime: !GetAtt StartTime.Utc | ||
TimeZone: "UTC-07" | ||
``` | ||
## Properties | ||
| Properties | Type | Description | | ||
| ------------- | ------------- | ------------- | | ||
| **Time** | string | Utc time to do the offset from. If none is provided now will be used. | ||
| **OffsetYears** | integer | Number of years to offset the base timestamp. | ||
| **OffsetMonths** | integer | Number of months to offset the base timestamp. | ||
| **OffsetDays** | integer | Number of days to offset the base timestamp. | ||
| **OffsetHours** | integer | Number of hours to offset the base timestamp. | ||
| **OffsetMinutes** | integer | Number of minutes to offset the base timestamp. | ||
| **OffsetSeconds** | integer | Number of seconds to offset the base timestamp. | ||
## Attributes | ||
The following properties you can use in a `GetAtt` | ||
|
||
| Attribute | Type | Description | | ||
| ------------- | ------------- | ------------- | | ||
| **Id** | string | Unique ID that identifies the resource. | ||
| **Day** | integer | Day returns the day of the month. | ||
| **Hour** | integer | Hour returns the hour within the day, in the range [0, 23]. | ||
| **Minute** | integer | Minute returns the minute offset within the hour, in the range [0, 59]. | ||
| **Month** | integer | Month returns the month of the year. | ||
| **Second** | integer | Second returns the second offset within the minute, in the range [0, 59]. | ||
| **Unix** | integer | Unix returns a Unix time, the number of seconds elapsed since January 1, 1970 UTC. | ||
| **Utc** | string | The time represented in UTC time | ||
| **Year** | integer | Year returns the year. | ||
|
||
## Development | ||
|
||
Open two tabs in your terminal. | ||
|
||
Run SAM | ||
```sh | ||
sam local start-lambda | ||
``` | ||
|
||
In another tab, run cfn test: | ||
|
||
```sh | ||
cd resources/Time_Offset | ||
cfn test | ||
``` | ||
|
||
## Notes | ||
|
||
### SSM Parameter | ||
Since this extension does not represent an actual resource, we have to create a Systems Manager Parameter Store entry to track its state for the purposes of satisfying the CloudFormation registry contract. We store a key in parameter store at `/CloudFormation/AwsCommunity/Time/Offset/unique-identifier`. |
Oops, something went wrong.