-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from org-formation/feat/s3-public-access-block
Implemented Community::S3::PublicAccessBlock Resource #11
- Loading branch information
Showing
30 changed files
with
832 additions
and
16 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
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
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
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
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
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,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/ |
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 @@ | ||
optional = true |
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 @@ | ||
{ | ||
"typeName": "Community::S3::PublicAccessBlock", | ||
"language": "typescript", | ||
"runtime": "nodejs12.x", | ||
"entrypoint": "dist/handlers.entrypoint", | ||
"testEntrypoint": "dist/handlers.testEntrypoint", | ||
"settings": { | ||
"useDocker": true, | ||
"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,39 @@ | ||
// Community::S3::PublicAccessBlock | ||
|
||
Congratulations on starting development! Next steps: | ||
|
||
1. Write the JSON schema describing your resource, [community-s3-publicaccessblock.json](./community-s3-publicaccessblock.json) | ||
2. Implement your resource handlers in [handlers.ts](./community-s3-publicaccessblock/handlers.ts) | ||
|
||
> Don't modify [models.ts](./community-s3-publicaccessblock/models.ts) by hand, any modifications will be overwritten when the `generate` or `package` commands are run. | ||
Implement CloudFormation resource here. Each function must always return a ProgressEvent. | ||
|
||
```typescript | ||
const progress: ProgressEvent = ProgressEvent.builder() | ||
|
||
// Required | ||
// Must be one of OperationStatus.InProgress, OperationStatus.Failed, OperationStatus.Success | ||
.status(OperationStatus.InProgress) | ||
// Required on SUCCESS (except for LIST where resourceModels is required) | ||
// The current resource model after the operation; instance of ResourceModel class | ||
.resourceModel(model) | ||
.resourceModels(null) | ||
// Required on FAILED | ||
// Customer-facing message, displayed in e.g. CloudFormation stack events | ||
.message('') | ||
// Required on FAILED a HandlerErrorCode | ||
.errorCode(HandlerErrorCode.InternalFailure) | ||
// Optional | ||
// Use to store any state between re-invocation via IN_PROGRESS | ||
.callbackContext({}) | ||
// Required on IN_PROGRESS | ||
// The number of seconds to delay before re-invocation | ||
.callbackDelaySeconds(0) | ||
|
||
.build() | ||
``` | ||
|
||
While importing the [cfn-rpdk](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. | ||
|
||
Keep in mind, during runtime all logs will be delivered to CloudWatch except those used with `debug` method. |
57 changes: 57 additions & 0 deletions
57
s3/public-access-block/community-s3-publicaccessblock.json
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,57 @@ | ||
{ | ||
"typeName": "Community::S3::PublicAccessBlock", | ||
"description": "Account level public access block (applies to all buckets within account).", | ||
"sourceUrl": "https://github.com/org-formation/aws-resource-providers.git", | ||
"definitions": { | ||
}, | ||
"properties": { | ||
"BlockPublicAcls": { | ||
"type": "boolean" | ||
}, | ||
"BlockPublicPolicy": { | ||
"type": "boolean" | ||
}, | ||
"IgnorePublicAcls": { | ||
"type": "boolean" | ||
}, | ||
"RestrictPublicBuckets": { | ||
"type": "boolean" | ||
}, | ||
"ResourceId": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"TestCode", | ||
"Title" | ||
], | ||
"readOnlyProperties": [ | ||
"/properties/ResourceId" | ||
], | ||
"primaryIdentifier": [ | ||
"/properties/ResourceId" | ||
], | ||
"handlers": { | ||
"create": { | ||
"permissions": [ | ||
"s3:PutAccountPublicAccessBlock" | ||
] | ||
}, | ||
"read": { | ||
"permissions": [ | ||
"s3:GetAccountPublicAccessBlock" | ||
] | ||
}, | ||
"update": { | ||
"permissions": [ | ||
"s3:PutAccountPublicAccessBlock" | ||
] | ||
}, | ||
"delete": { | ||
"permissions": [ | ||
"s3:PutAccountPublicAccessBlock" | ||
] | ||
} | ||
} | ||
} |
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,83 @@ | ||
# Community::S3::PublicAccessBlock | ||
|
||
Account level public access block (applies to all buckets within account). | ||
|
||
## Syntax | ||
|
||
To declare this entity in your AWS CloudFormation template, use the following syntax: | ||
|
||
### JSON | ||
|
||
<pre> | ||
{ | ||
"Type" : "Community::S3::PublicAccessBlock", | ||
"Properties" : { | ||
"<a href="#blockpublicacls" title="BlockPublicAcls">BlockPublicAcls</a>" : <i>Boolean</i>, | ||
"<a href="#blockpublicpolicy" title="BlockPublicPolicy">BlockPublicPolicy</a>" : <i>Boolean</i>, | ||
"<a href="#ignorepublicacls" title="IgnorePublicAcls">IgnorePublicAcls</a>" : <i>Boolean</i>, | ||
"<a href="#restrictpublicbuckets" title="RestrictPublicBuckets">RestrictPublicBuckets</a>" : <i>Boolean</i>, | ||
} | ||
} | ||
</pre> | ||
|
||
### YAML | ||
|
||
<pre> | ||
Type: Community::S3::PublicAccessBlock | ||
Properties: | ||
<a href="#blockpublicacls" title="BlockPublicAcls">BlockPublicAcls</a>: <i>Boolean</i> | ||
<a href="#blockpublicpolicy" title="BlockPublicPolicy">BlockPublicPolicy</a>: <i>Boolean</i> | ||
<a href="#ignorepublicacls" title="IgnorePublicAcls">IgnorePublicAcls</a>: <i>Boolean</i> | ||
<a href="#restrictpublicbuckets" title="RestrictPublicBuckets">RestrictPublicBuckets</a>: <i>Boolean</i> | ||
</pre> | ||
|
||
## Properties | ||
|
||
#### BlockPublicAcls | ||
|
||
_Required_: No | ||
|
||
_Type_: Boolean | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### BlockPublicPolicy | ||
|
||
_Required_: No | ||
|
||
_Type_: Boolean | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### IgnorePublicAcls | ||
|
||
_Required_: No | ||
|
||
_Type_: Boolean | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### RestrictPublicBuckets | ||
|
||
_Required_: No | ||
|
||
_Type_: Boolean | ||
|
||
_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 | ||
|
||
Returns the <code>ResourceId</code> value. | ||
|
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,9 @@ | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
Resources: | ||
S3AccountPublicAccessBlock: | ||
Type: 'Community::S3::PublicAccessBlock' | ||
Properties: | ||
BlockPublicAcls: true | ||
BlockPublicPolicy: false | ||
IgnorePublicAcls: true | ||
RestrictPublicBuckets: true |
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 @@ | ||
# Community::S3::PublicAccessBlock | ||
|
||
## Installation using AWS CLI | ||
``` bash | ||
aws cloudformation register-type \ | ||
--type-name Community::S3::PublicAccessBlock \ | ||
--type RESOURCE \ | ||
--schema-handler-package s3://community-resource-provider-catalog/community-s3-publicaccessblock-0.1.0.zip | ||
|
||
aws cloudformation describe-type-registration --registration-token <registration-token> | ||
|
||
aws cloudformation set-type-default-version \ | ||
--version-id <version-id> \ | ||
--type-name Community::S3::PublicAccessBlock \ | ||
--type RESOURCE | ||
|
||
``` |
Oops, something went wrong.