Skip to content

Commit

Permalink
Add support for AWS::IoT::Dimension (#12)
Browse files Browse the repository at this point in the history
* Add support for AWS::IoT::Dimension

* Add improvements for the second revision for Dimension PR

* Add improvements for the third revision

* Incorporate more feedback

* Add more improvements

* Use ProgressEvents instead of Cfn exceptions
  • Loading branch information
anton-aws authored Dec 16, 2020
1 parent c17580f commit 2ab36d7
Show file tree
Hide file tree
Showing 29 changed files with 2,041 additions and 0 deletions.
24 changes: 24 additions & 0 deletions aws-iot-dimension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# macOS
.DS_Store
._*

# Maven outputs
.classpath

# IntelliJ
*.iml
.idea
out.java
out/
.settings
.project

# auto-generated files
target/
.hypothesis/

# our logs
rpdk.log

# contains credentials
sam-tests/
17 changes: 17 additions & 0 deletions aws-iot-dimension/.rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"typeName": "AWS::IoT::Dimension",
"language": "java",
"runtime": "java8",
"entrypoint": "com.amazonaws.iot.dimension.HandlerWrapper::handleRequest",
"testEntrypoint": "com.amazonaws.iot.dimension.HandlerWrapper::testEntrypoint",
"settings": {
"namespace": [
"com",
"amazonaws",
"iot",
"dimension"
],
"codegen_template_path": "default",
"protocolVersion": "2.0.0"
}
}
19 changes: 19 additions & 0 deletions aws-iot-dimension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# AWS::IoT::Dimension

## Running Contract Tests

You can execute the following commands to run the tests.
You will need to have docker installed and running.

```bash
# Package the code with Maven
mvn package
# Start SAM which will execute lambdas in Docker
sam local start-lambda

# In a separate terminal, run the contract tests
cfn test --enforce-timeout 240

# Execute a single test
cfn test --enforce-timeout 240 -- -k <testname>
```
120 changes: 120 additions & 0 deletions aws-iot-dimension/aws-iot-dimension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"typeName": "AWS::IoT::Dimension",
"description": "A dimension can be used to limit the scope of a metric used in a security profile for AWS IoT Device Defender.",
"sourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-iot.git",
"definitions": {
"Tag": {
"description": "A key-value pair to associate with a resource.",
"type": "object",
"properties": {
"Key": {
"type": "string",
"description": "The tag's key.",
"minLength": 1,
"maxLength": 128
},
"Value": {
"type": "string",
"description": "The tag's value.",
"minLength": 1,
"maxLength": 256
}
},
"required": [
"Value",
"Key"
],
"additionalProperties": false
}
},
"properties": {
"Name": {
"description": "A unique identifier for the dimension.",
"type": "string",
"pattern": "[a-zA-Z0-9:_-]+",
"minLength": 1,
"maxLength": 128
},
"Type": {
"description": "Specifies the type of the dimension.",
"type": "string",
"enum": [
"TOPIC_FILTER"
]
},
"StringValues": {
"description": "Specifies the value or list of values for the dimension.",
"type": "array",
"uniqueItems": true,
"insertionOrder": false,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"minItems": 1,
"maxItems": 5
},
"Tags": {
"description": "Metadata that can be used to manage the dimension.",
"type": "array",
"maxItems": 50,
"uniqueItems": true,
"insertionOrder": false,
"items": {
"$ref": "#/definitions/Tag"
}
},
"Arn": {
"description": "The ARN (Amazon resource name) of the created dimension.",
"type": "string"
}
},
"additionalProperties": false,
"primaryIdentifier": [
"/properties/Name"
],
"required": [
"Type",
"StringValues"
],
"createOnlyProperties": [
"/properties/Name",
"/properties/Type"
],
"readOnlyProperties": [
"/properties/Arn"
],
"handlers": {
"create": {
"permissions": [
"iot:CreateDimension"
]
},
"read": {
"permissions": [
"iot:DescribeDimension",
"iot:ListTagsForResource"
]
},
"update": {
"permissions": [
"iot:UpdateDimension",
"iot:ListTagsForResource",
"iot:UntagResource",
"iot:TagResource"
]
},
"delete": {
"permissions": [
"iot:DescribeDimension",
"iot:DeleteDimension"
]
},
"list": {
"permissions": [
"iot:ListDimensions"
]
}
}
}
13 changes: 13 additions & 0 deletions aws-iot-dimension/inputs/inputs_1_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Name": "CfnContractTest",
"StringValues": [
"device/+/auth"
],
"Type": "TOPIC_FILTER",
"Tags": [
{
"Key": "testTagKey",
"Value": "tagValue"
}
]
}
8 changes: 8 additions & 0 deletions aws-iot-dimension/inputs/inputs_1_invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Name": "CfnContractTest-Invalid",
"StringValues": [
"device/+/auth"
],
"Type": "TOPIC_FILTER",
"Arn": "Arn is a read-only property"
}
13 changes: 13 additions & 0 deletions aws-iot-dimension/inputs/inputs_1_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Name": "CfnContractTest",
"StringValues": [
"device/+/authV2"
],
"Type": "TOPIC_FILTER",
"Tags": [
{
"Key": "cfnTestTagKey2",
"Value": "tagValue2"
}
]
}
1 change: 1 addition & 0 deletions aws-iot-dimension/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
Loading

0 comments on commit 2ab36d7

Please sign in to comment.