-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for AWS::IoT::MitigationAction #15
Changes from 4 commits
8fc28dc
d5cf3ff
90588d5
8ba164e
2244540
2b99a7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# macOS | ||
.DS_Store | ||
._* | ||
|
||
# Maven outputs | ||
.classpath | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea | ||
out.java | ||
out/ | ||
.settings | ||
.project | ||
|
||
# auto-generated files | ||
target/ | ||
|
||
# our logs | ||
rpdk.log | ||
|
||
# contains credentials | ||
sam-tests/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"typeName": "AWS::IoT::MitigationAction", | ||
"language": "java", | ||
"runtime": "java8", | ||
"entrypoint": "com.amazonaws.iot.mitigationaction.HandlerWrapper::handleRequest", | ||
"testEntrypoint": "com.amazonaws.iot.mitigationaction.HandlerWrapper::testEntrypoint", | ||
"settings": { | ||
"namespace": [ | ||
"com", | ||
"amazonaws", | ||
"iot", | ||
"mitigationaction" | ||
], | ||
"codegen_template_path": "guided_aws", | ||
"protocolVersion": "2.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# AWS::IoT::MitigationAction | ||
|
||
## Running Contract Tests | ||
|
||
You can execute the following commands to run the tests. | ||
You will need to have docker installed and running. | ||
|
||
```bash | ||
# Create a CloudFormation stack with contract test dependencies (an IAM Role) | ||
aws cloudformation deploy \ | ||
--stack-name cfn-contract-test-dependencies-mitigation-action \ | ||
--template-file packaging_additional_published_artifacts/contract_test_dependencies.yml \ | ||
--capabilities CAPABILITY_IAM \ | ||
--region us-east-1 | ||
# 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> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
{ | ||
"typeName": "AWS::IoT::MitigationAction", | ||
"description": "Mitigation actions can be used to take actions to mitigate issues that were found during an audit.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mitigation Action isn't specific to Audit, now even ML Detect uses it. So lets paraphrase There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
"sourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-iot.git", | ||
"definitions": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add |
||
"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 | ||
}, | ||
"ActionParams": { | ||
"type": "object", | ||
"description": "The set of parameters for this mitigation action. You can specify only one type of parameter (in other words, you can apply only one action for each defined mitigation action).", | ||
"properties": { | ||
"AddThingsToThingGroupParams": { | ||
"$ref": "#/definitions/AddThingsToThingGroupParams" | ||
}, | ||
"EnableIoTLoggingParams": { | ||
"$ref": "#/definitions/EnableIoTLoggingParams" | ||
}, | ||
"PublishFindingToSnsParams": { | ||
"$ref": "#/definitions/PublishFindingToSnsParams" | ||
}, | ||
"ReplaceDefaultPolicyVersionParams": { | ||
"$ref": "#/definitions/ReplaceDefaultPolicyVersionParams" | ||
}, | ||
"UpdateCACertificateParams": { | ||
"$ref": "#/definitions/UpdateCACertificateParams" | ||
}, | ||
"UpdateDeviceCertificateParams": { | ||
"$ref": "#/definitions/UpdateDeviceCertificateParams" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"AddThingsToThingGroupParams": { | ||
"description": "Parameters to define a mitigation action that moves devices associated with a certificate to one or more specified thing groups, typically for quarantine.", | ||
"type": "object", | ||
"properties": { | ||
"OverrideDynamicGroups": { | ||
"type": "boolean", | ||
"description": "Specifies if this mitigation action can move the things that triggered the mitigation action out of one or more dynamic thing groups." | ||
}, | ||
"ThingGroupNames": { | ||
"description": "The list of groups to which you want to add the things that triggered the mitigation action.", | ||
"type": "array", | ||
"uniqueItems": true, | ||
"items": { | ||
"type": "string", | ||
"minLength": 1, | ||
"maxLength": 128 | ||
}, | ||
"minItems": 1, | ||
"maxItems": 10, | ||
"insertionOrder": false | ||
} | ||
}, | ||
"required": [ | ||
"ThingGroupNames" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"EnableIoTLoggingParams": { | ||
"description": "Parameters to define a mitigation action that enables AWS IoT logging at a specified level of detail.", | ||
"type": "object", | ||
"properties": { | ||
"LogLevel": { | ||
"type": "string", | ||
"enum": [ | ||
"DEBUG", | ||
"INFO", | ||
"ERROR", | ||
"WARN" | ||
], | ||
"description": " Specifies which types of information are logged." | ||
}, | ||
"RoleArnForLogging": { | ||
"description": " The ARN of the IAM role used for logging.", | ||
"type": "string", | ||
"minLength": 20, | ||
"maxLength": 2048 | ||
} | ||
}, | ||
"required": [ | ||
"LogLevel", | ||
"RoleArnForLogging" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"PublishFindingToSnsParams": { | ||
"type": "object", | ||
"description": "Parameters, to define a mitigation action that publishes findings to Amazon SNS. You can implement your own custom actions in response to the Amazon SNS messages.", | ||
"properties": { | ||
"TopicArn": { | ||
"type": "string", | ||
"description": "The ARN of the topic to which you want to publish the findings.", | ||
"minLength": 20, | ||
"maxLength": 2048 | ||
} | ||
}, | ||
"required": [ | ||
"TopicArn" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"ReplaceDefaultPolicyVersionParams": { | ||
"type": "object", | ||
"description": "Parameters to define a mitigation action that adds a blank policy to restrict permissions.", | ||
"properties": { | ||
"TemplateName": { | ||
"type": "string", | ||
"enum": [ | ||
"BLANK_POLICY" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"TemplateName" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"UpdateCACertificateParams": { | ||
"type": "object", | ||
"description": "Parameters to define a mitigation action that changes the state of the CA certificate to inactive.s", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo s/inactive.s/inactive./g There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
"properties": { | ||
"Action": { | ||
"type": "string", | ||
"enum": [ | ||
"DEACTIVATE" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"Action" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"UpdateDeviceCertificateParams": { | ||
"type": "object", | ||
"description": "Parameters to define a mitigation action that changes the state of the device certificate to inactive.", | ||
"properties": { | ||
"Action": { | ||
"type": "string", | ||
"enum": [ | ||
"DEACTIVATE" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"Action" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"properties": { | ||
"ActionName": { | ||
"description": "A unique identifier for the mitigation action.", | ||
"type": "string", | ||
"pattern": "[a-zA-Z0-9:_-]+", | ||
"minLength": 1, | ||
"maxLength": 128 | ||
}, | ||
"RoleArn": { | ||
"type": "string" | ||
}, | ||
"Tags": { | ||
"type": "array", | ||
"maxItems": 50, | ||
"uniqueItems": true, | ||
"insertionOrder": false, | ||
"description": "An array of key-value pairs to apply to this resource.", | ||
"items": { | ||
"$ref": "#/definitions/Tag" | ||
} | ||
}, | ||
"ActionParams": { | ||
"$ref": "#/definitions/ActionParams" | ||
}, | ||
"MitigationActionArn": { | ||
"type": "string" | ||
}, | ||
"MitigationActionId": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"primaryIdentifier": [ | ||
"/properties/ActionName" | ||
], | ||
"required": [ | ||
"RoleArn", | ||
"ActionParams" | ||
], | ||
"createOnlyProperties": [ | ||
"/properties/ActionName" | ||
], | ||
"readOnlyProperties": [ | ||
"/properties/MitigationActionArn", | ||
"/properties/MitigationActionId" | ||
], | ||
"handlers": { | ||
"create": { | ||
"permissions": [ | ||
"iot:CreateMitigationAction", | ||
"iam:PassRole" | ||
] | ||
}, | ||
"read": { | ||
"permissions": [ | ||
"iot:DescribeMitigationAction", | ||
"iot:ListTagsForResource" | ||
] | ||
}, | ||
"update": { | ||
"permissions": [ | ||
"iot:UpdateMitigationAction", | ||
"iot:ListTagsForResource", | ||
"iot:UntagResource", | ||
"iot:TagResource", | ||
"iam:PassRole" | ||
] | ||
}, | ||
"delete": { | ||
"permissions": [ | ||
"iot:DescribeMitigationAction", | ||
"iot:DeleteMitigationAction" | ||
] | ||
}, | ||
"list": { | ||
"permissions": [ | ||
"iot:ListMitigationActions" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"ActionName": "CfnContractTest", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be nice to have a test for every single action that we support, else how do you know that the definition of one of the actions isn't broken? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding an integ test for them in the integ test package. |
||
"RoleArn": "{{RoleForDeviceDefenderAuditArn}}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not use "Audit" in names of even the test resource. Reason being MitigationActions isn't specific to Audit anymore (it's a common resource to both Audit/Detect) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
"ActionParams": { | ||
"PublishFindingToSnsParams": { | ||
"TopicArn": "{{TopicForDeviceDefenderAuditCreateArn}}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 👍 |
||
} | ||
}, | ||
"Tags": [ | ||
{ | ||
"Key": "testTagKey", | ||
"Value": "tagValue" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"ActionName": "CfnContractTest", | ||
"RoleArn": "{{RoleForDeviceDefenderAuditArn}}", | ||
"ActionParams": { | ||
"PublishFindingToSnsParams": { | ||
"TopicArn": "{{TopicForDeviceDefenderAuditCreateArn}}" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, do not use Audit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
}, | ||
"MitigationActionId": "This is a read only property" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"ActionName": "CfnContractTest", | ||
"RoleArn": "{{RoleForDeviceDefenderAuditArn}}", | ||
"ActionParams": { | ||
"PublishFindingToSnsParams": { | ||
"TopicArn": "{{TopicForDeviceDefenderAuditUpdateArn}}" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON files are showing big delta because of fixing indentation using pre-commit hook.