aws-cloudformation / aws-cloudformation-resource-providers-cloudformation

The CloudFormation Resource Provider Package For AWS CloudFormation
https://aws.amazon.com/cloudformation/
Apache License 2.0
48 stars 35 forks source link

Resource implementations for AWS::CloudFormation::ResourceVersion and AWS::CloudFormation::ResourceDefaultVersion #4

Closed rjlohan closed 4 years ago

rjlohan commented 4 years ago

Issue #, if available: #3

Description of changes:

Schema and handler implementations for AWS::CloudFormation::ResourceVersion and AWS::CloudFormation::ResourceDefaultVersion.

Sample template for use of these type;

Resources:
    InitialType:
        Type: AWS::CloudFormation::ResourceVersion
        Properties:
            TypeName: Sample::CloudFormation::Resource
            SchemaHandlerPackage: s3://cloudformationmanageduploadinfrast-artifactbucket-123456789012abcdef/sample-cloudformation-resource.zip
    UpdatedType:
        Type: AWS::CloudFormation::ResourceVersion
        Properties:
            TypeName: Sample::CloudFormation::Resource
            SchemaHandlerPackage: s3://cloudformationmanageduploadinfrast-artifactbucket-123456789012abcdef/sample-cloudformation-resource-update.zip
        DependsOn: InitialType

    DefaultVersion:
        Type: AWS::CloudFormation::ResourceDefaultVersion
        Properties:
            Arn: !Ref UpdatedType

Pending contract test verification.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

benkehoe commented 4 years ago

The Registry restricts only a single in-flight registerType action for a type, so this ordering ensures that we don't attempt to register both at once as that will fail.

Right. This is off topic, but it seems useful if you could put something like "serializedProperties": [ "TypeName" ] in your ::ResourceVersion schema and CloudFormation would make sure it's only running one operation at a time for ::ResourceVersion resources with a common TypeName (of Sample::CloudFormation::Resource in this case)

benbridts commented 4 years ago

The Registry restricts only a single in-flight registerType action for a type, so this ordering ensures that we don't attempt to register both at once as that will fail.

Right. This is off topic, but it seems useful if you could put something like "serializedProperties": [ "TypeName" ] in your ::ResourceVersion schema and CloudFormation would make sure it's only running one operation at a time for ::ResourceVersion resources with a common TypeName (of Sample::CloudFormation::Resource in this case)

Even more off-topic: it would be even better if it could accept a number (eg. for dynamodb tables where there can be 10 creates at the same time)

rjlohan commented 4 years ago

The Registry restricts only a single in-flight registerType action for a type, so this ordering ensures that we don't attempt to register both at once as that will fail.

Right. This is off topic, but it seems useful if you could put something like "serializedProperties": [ "TypeName" ] in your ::ResourceVersion schema and CloudFormation would make sure it's only running one operation at a time for ::ResourceVersion resources with a common TypeName (of Sample::CloudFormation::Resource in this case)

Even more off-topic: it would be even better if it could accept a number (eg. for dynamodb tables where there can be 10 creates at the same time)

Have you started this ask on the roadmap yet? Let's take it there. What you're really asking for is a customer-driven throttling control. I can see value, but needs more deep dive and I can't speak to priority.

benkehoe commented 4 years ago

I opened it on the schema repo here: https://github.com/aws-cloudformation/aws-cloudformation-resource-schema/issues/79 . Should I open it on the roadmap instead?

rjlohan commented 4 years ago

I opened it on the schema repo here: aws-cloudformation/aws-cloudformation-resource-schema#79 . Should I open it on the roadmap instead?

No that's OK.

rjlohan commented 4 years ago

I believe this version of the PR to be finalised. It depends on 2 pending changes in the Java plugin repo if testing;

It also needs a Maven-published version of https://github.com/aws-cloudformation/cloudformation-cli-java-plugin-testing-support for completion.

rjlohan commented 4 years ago

Contract tests for AWS::CloudFormation::ResourceVersion are now functional with 2 exceptions;

=========================================================================================================== test session starts ============================================================================================================
platform darwin -- Python 3.7.5, pytest-5.4.1, py-1.8.0, pluggy-0.13.1 -- /Users/ryanloha/workspaces/cloudformation-cli/env/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/ryanloha/workspaces/aws-cloudformation-resource-providers-cloudformation/aws-cloudformation-resourceversion/.hypothesis/examples')
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /Users/ryanloha/workspaces/aws-cloudformation-resource-providers-cloudformation/aws-cloudformation-resourceversion, inifile: /private/var/folders/w8/jwm15b8n64l4gwc9ctjs4w4xj27kh4/T/pytest_eunwx3t0.ini
plugins: hypothesis-4.53.2, localserver-0.5.0, random-order-1.0.4, cov-2.8.1
collected 16 items / 5 deselected / 11 selected                                                                                                                                                                                            

handler_create.py::contract_create_delete PASSED                                                                                                                                                                                     [  9%]
handler_create.py::contract_invalid_create PASSED                                                                                                                                                                                    [ 18%]
handler_create.py::contract_create_duplicate PASSED                                                                                                                                                                                  [ 27%]
handler_create.py::contract_create_read_success PASSED                                                                                                                                                                               [ 36%]
handler_create.py::contract_create_list_success PASSED                                                                                                                                                                               [ 45%]
handler_delete.py::contract_delete_read PASSED                                                                                                                                                                                       [ 54%]
handler_delete.py::contract_delete_list PASSED                                                                                                                                                                                       [ 63%]
handler_delete.py::contract_delete_delete PASSED                                                                                                                                                                                     [ 72%]
handler_delete.py::contract_delete_create SKIPPED                                                                                                                                                                                    [ 81%]
handler_misc.py::contract_check_asserts_work PASSED                                                                                                                                                                                  [ 90%]
handler_read.py::contract_read_without_create FAILED                                                                                                                                                                                 [100%]

NOTE: ListHandler is removed from the schema for now as it requires careful implementation to change to list versions not just types. That would be simpler as a Registry API than as pagination-within-pagination against the ListTypes API.

aygold92 commented 4 years ago

lets get this out and we can iterate on it