Code Monkey home page Code Monkey logo

aws-cloudformation-resource-providers-synthetics's Introduction

AWS CloudFormation Resource Provider Package For AWS::Synthetics::* namespace.

Usage

The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.

Refer to the documentation for the CloudFormation CLI for usage instructions.

Development

First, you will need to install the CloudFormation CLI, as it is a required dependency:

pip3 install cloudformation-cli
pip3 install cloudformation-cli-java-plugin

Linting and running unit tests is done via pre-commit, and so is performed automatically on commit. The continuous integration also runs these checks.

pre-commit install

Manual options are available so you don't have to commit:

# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
# run unit tests and coverage checks
mvn verify

License

This library is licensed under the Apache 2.0 License.

aws-cloudformation-resource-providers-synthetics's People

Contributors

amazon-auto avatar aolsh99 avatar dependabot[bot] avatar dschinde avatar jingweicfn avatar patmyron avatar shukrash avatar swasts avatar thinksanky avatar yeshravindra avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aws-cloudformation-resource-providers-synthetics's Issues

Bug: Handler does not properly fail request if the canary's status has a 'StateReason'

During stabilization, the handler needs to be checking if StateReason is being returned from the request. The presence of this value indicates that there was an error and that the canary did not successfully update as intended. Currently, the handler is still treating this as a successful update. This can cause CloudFormation to register a bad deployment as a successful update.

As an example, here is a canary that it not in a stable state. This should be causing CloudFormation updates to fail, but it is not:

% aws synthetics get-canary --name <REDACTED>
{
    "Canary": {
        "Id": <REDACTED>,
        "Name": <REDACTED>,
        "Code": {
            "SourceLocationArn": <REDACTED>,
            "Handler": <REDACTED>
        },
        "ExecutionRoleArn": <REDACTED>,
        "Schedule": {
            "Expression": "rate(5 minutes)",
            "DurationInSeconds": 0
        },
        "RunConfig": {
            "TimeoutInSeconds": 300,
            "MemoryInMB": 960
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "RUNNING",
            "StateReason": "Error occurred while DescribeSecurityGroups. EC2 Error Code: InvalidGroup.NotFound. EC2 Error Message: The security group <REDACTED> does not exist (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException; Request ID :<REDACTED>; Proxy: null)"
        },
        "Timeline": {
            "Created": 1593634958.304,
            "LastModified": 1598909334.057,
            "LastStarted": 1598909344.0
        },
        "ArtifactS3Location": <REDACTED>,
        "EngineArn": <REDACTED>,
        "RuntimeVersion": "syn-1.0",
        "Tags": {}
    }
}

It looks like the model JSON also needs to be updated to be able to support this, see here where it only has State.

When performing the Update (and most likely in the Create handler as well), the handler needs to check that there is no StateReason returned before considering the request successful, see here.

RunConfig TimeoutInSeconds should not be required

From what says the documentation, TimeoutInSeconds should not be required since a default behavior seems implemented on service side:

TimeoutInSeconds
How long the canary is allowed to run before it must stop. You can't set this time to be longer than the frequency of the runs of this canary.

If you omit this field, the frequency of the canary is used as this value, up to a maximum of 900 seconds.

Required: Yes

Upgrading to RPDK 2.0 is failing model validation

Before:
My schema has a property called Code as follows:

"Code" : {
            "type" : "object",
            "additionalProperties" : false,
            "properties" : {
                "S3Bucket": {
                    "type": "string"
                },
                "S3Key": {
                    "type": "string"
                },
                "S3ObjectVersion": {
                    "type": "string"
                },
                "Script": {
                    "type": "string"
                },
                "Handler": {
                    "type": "string"
                }
            },
            "oneOf":[
                {
                    "required":[
                        "S3Bucket",
                        "S3Key",
                        "Handler"
                    ]
                },
                {
                    "required":[
                        "Script",
                        "Handler"
                    ]
                }
            ]
        }

Before upgrade to 2.0 from 1.1 there was no error during creating the stack in my integration tests.

But after upgrading to 2.0, I am seeing the following validation error during stack creation ( canary creation which. my resource )

Model validation failed (#/Code: #: only 1 subschema matches out of 2) #/Code: #: 0 subschemas matched instead of one (#/Code)

Here is the input template for Code

Code:
        Handler: "pageLoadBlueprint.handler"
        S3Bucket: !Join [ '', ['aws-synthetics-code-', !Ref 'AWS::AccountId', '-',  !Ref 'AWS::Region' ] ]
        S3Key: "canary/dnd-amazon-hb-blue.zip"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.