Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
initial resource provider code
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed Aug 9, 2020
0 parents commit 0c154b5
Show file tree
Hide file tree
Showing 15 changed files with 720 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Distribution / packaging
build/
dist/

# Unit test / coverage reports
.cache
.hypothesis/
.pytest_cache/

# RPDK logs
rpdk.log

# Node.js
node_modules/
coverage/

# contains credentials
sam-tests/
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# optional = false
save = false
12 changes: 12 additions & 0 deletions .rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"typeName": "OC::CloudFormation::Delay",
"language": "typescript",
"runtime": "nodejs12.x",
"entrypoint": "dist/handlers.entrypoint",
"testEntrypoint": "dist/handlers.testEntrypoint",
"settings": {
"useDocker": false,
"protocolVersion": "2.0.0",
"buildCommand": "npm run build && NPM_CONFIG_OPTIONAL=0 NPM_CONFIG_FUND=0 sam build --build-dir ./build --debug"
}
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

## [0.1.0] - 2020-08-10
### Added
- Handlers for CRUDL methods leveraging CloudFormation support protocol version v2.0


[Unreleased]: https://github.com/eduardomourar/aws-resource-provider-passwordpolicy/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/eduardomourar/aws-resource-provider-passwordpolicy/releases/tag/v0.1.0
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# AWS::CloudFormation::Delay

This CloudFormation Resource Provider is very similar to [AWS::CloudFormation::WaitCondition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitcondition.html), except that we don't need to wait for an external process, only for a period of time (more context [here](https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/589)).

## Resource and Property Reference

Check the [Resource and Property Types Reference documentation](./docs/README.md) that was generated from the JSON schema describing the resource called [Resource Provider Schema](./oc-cloudformation-delay.json).

## Usage

1. Run `npm install --optional`
2. Customize the resource handlers to your needs in [handlers.ts](./src/handlers.ts)
3. Build the project with `npm run build`
4. You can test it locally with SAM CLI
5. Follow the steps on the AWS documentation to submit to the CloudFormation registry: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-types.html
6. Use [this template](./sample.yml) to deploy a sample delay resource

> Don't modify [models.ts](./src/models.ts) by hand, any modifications will be overwritten when the `generate` or `package` commands are run.
Keep in mind, during runtime all logs will be delivered to CloudWatch except those used with `debug` method.
57 changes: 57 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# OC::CloudFormation::Delay

Resource schema for OC::CloudFormation::Delay.

## Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

### JSON

<pre>
{
"Type" : "OC::CloudFormation::Delay",
"Properties" : {
"<a href="#duration" title="Duration">Duration</a>" : <i>String</i>
}
}
</pre>

### YAML

<pre>
Type: OC::CloudFormation::Delay
Properties:
<a href="#duration" title="Duration">Duration</a>: <i>String</i>
</pre>

## Properties

#### Duration

The length of time that AWS CloudFormation waits. The maximum time that you can specify is 12 hours. The value must be in ISO8601 duration format, in the form: "PT#H#M#S", where each # is the number of hours, minutes, and seconds, respectively.

_Required_: No

_Type_: String

_Pattern_: <code>^PT(?=[0-9])([0-1]?[0-9]H)?([0-9]+M)?([0-9]+S)?$</code>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return Values

### Ref

When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the ResourceId.

### Fn::GetAtt

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.

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).

#### ResourceId

AWS CloudFormation generates a unique identifier for the delay resource.

49 changes: 49 additions & 0 deletions oc-cloudformation-delay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"typeName": "OC::CloudFormation::Delay",
"description": "Resource schema for OC::CloudFormation::Delay.",
"sourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
"definitions": {},
"properties": {
"ResourceId": {
"description": "AWS CloudFormation generates a unique identifier for the delay resource.",
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"Duration": {
"description": "The length of time that AWS CloudFormation should wait. The maximum time that you can specify is 12 hours. The value must be in ISO8601 duration format, in the form: \"PT#H#M#S\", where each # is the number of hours, minutes, and seconds, respectively.",
"type": "string",
"default": "PT1M",
"minLength": 4,
"maxLength": 15,
"pattern": "^PT(?=[0-9])([0-1]?[0-9]H)?([0-9]{1,3}M)?([0-9]{1,5}S)?$"
}
},
"additionalProperties": false,
"required": [],
"createOnlyProperties": [
"/properties/ResourceId"
],
"readOnlyProperties": [
"/properties/ResourceId"
],
"primaryIdentifier": [
"/properties/ResourceId"
],
"handlers": {
"create": {
"permissions": []
},
"read": {
"permissions": []
},
"update": {
"permissions": []
},
"delete": {
"permissions": []
},
"list": {
"permissions": []
}
}
}
172 changes: 172 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "aws-cloudformation-delay",
"version": "0.1.0",
"description": "CloudFormation Resource Provider for AWS CloudFormation Delay",
"main": "dist/handlers.js",
"files": [
"dist"
],
"scripts": {
"build": "npx tsc",
"prepack": "npm run build",
"start": "sam local start-lambda",
"test": "cfn test",
"package": "cfn submit --dry-run -vv",
"submit": "cfn submit --set-default -vv"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eduardomourar/aws-resource-provider-delay.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/eduardomourar/aws-resource-provider-delay/issues"
},
"homepage": "https://github.com/eduardomourar/aws-resource-provider-delay#readme",
"dependencies": {
"cfn-rpdk": "https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/releases/download/v0.3.0/cfn-rpdk-0.3.0.tgz",
"class-transformer": "^0.3.1"
},
"devDependencies": {
"@types/node": "^12.0.0",
"typescript": "^3.8.3"
}
}
Loading

0 comments on commit 0c154b5

Please sign in to comment.