Skip to content
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

Statically typed CloudFormation Templates #401

Merged
merged 8 commits into from
Nov 5, 2015

Conversation

rosenhouse
Copy link
Contributor

A draft, and not feature-complete. Feedback appreciated.

Context from my original issue #393:

I'm trying to programmatically generate CloudFormation templates.

cloudformation.CreateStackInput has its TemplateBody field typed as a *string. I'd like to be able to build up a strongly-typed Template in memory, call json.Marshal() and use the result as the TemplateBody.

I've roughly followed the approach outlined by @jasdel . One difference is that the intrinsic Fn::x and Ref functions are modeled as Go functions, not types. It makes the usage syntax a bit cleaner:

FnJoin("\n", "Stack ID is:", Ref("AWS::StackId") )

instead of

FnJoin{ "\n", []interface{}{ "Stack ID is:", Ref{ "AWS::StackId" } } }

But perhaps there are some drawbacks I haven't considered. And regardless, you'll probably want to dot-import this package.

What's missing:

It would be great to auto-generate the resource and resource-property types somehow.

But I wanted to get feedback before I invested too much more time.

@jasdel jasdel added help wanted We are asking the community to submit a PR to resolve this issue. review needed labels Oct 19, 2015
@jasdel
Copy link
Contributor

jasdel commented Oct 19, 2015

Hi @rosenhouse thanks a lot for taking the time and putting this preliminary PR. I'm looking for predefined models of the template shapes to see if there is something we can use to generate code from. In the mean time I'll review the PR and get back to you with feedback.

Using helper functions instead of structs for Fn::x should work just as well too.

@rosenhouse
Copy link
Contributor Author

@jasdel: Any update here? Would you be open to merging this PR as it currently stands? We could follow up later on with the generated resource & resource-property structs.

assertEquivalentJSON(t, expectedJSON, string(actual))
}

func assertEquivalentJSON(t *testing.T, expected, actual string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can assertEquivalentJSON be replaced with awstesting.AssertJSON? , they look similar.

@jasdel
Copy link
Contributor

jasdel commented Nov 5, 2015

Thanks a lot for your hard work getting this PR together @rosenhouse. It looks good and I think we can pull it in.

I agree being able to generate the code would be the best plan, especially for the resources and property resources. The .NET SDK uses a JSON scheme for their Visual Studio's CloudFormation Template generator wizard. I'm investigating if it is possible for the Go SDK to reuse the scheme for our resource and resource-property structs.

@rosenhouse
Copy link
Contributor Author

Thanks for the review. I've rebased against master, replaced my assertEquivalentJSON with awstesting.AssertJSON and added a package doc header.

jasdel added a commit that referenced this pull request Nov 5, 2015
Add Statically typed CloudFormation Templates
@jasdel jasdel merged commit 87173d6 into aws:master Nov 5, 2015
@jasdel
Copy link
Contributor

jasdel commented Nov 5, 2015

Looks great, thanks, and I merged the change in. This will be a great place to get started building templates programmatically. I'll update #393 when more information is available about auto generating the resources and resource-properties.

@rosenhouse rosenhouse deleted the cloudformation-templates branch November 5, 2015 22:44
@rosenhouse
Copy link
Contributor Author

Great, thank you!

jasdel added a commit that referenced this pull request Nov 10, 2015
skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this pull request May 20, 2021
skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this pull request May 20, 2021
### Services
* Synced the V2 SDK with latest AWS service API definitions.

### SDK Breaking changes
* This update includes breaking changes to how the DynamoDB AttributeValue (un)marshier handles empty collections.

### Deprecations
* `service/s3/s3crypto`: Deprecates the crypto client from the SDK ([aws#394](aws/aws-sdk-go-v2#394))
  * s3crypto client is now deprecated and may be removed from the future versions of the SDK.
* `aws`: Removes plugin credential provider ([aws#391](aws/aws-sdk-go-v2#391))
  * Removing plugin credential provider from the v2 SDK developer preview. This feature may be made available as a separate module.
* Removes support for deprecated Go versions ([aws#393](aws/aws-sdk-go-v2#393))
  * Removes support for Go version specific files from the SDK. Also removes irrelevant build tags, and updates the README.md file.
  * Raises the minimum supported version to Go 1.11 for the SDK. Older versions may work, but are not actively supported

### SDK Features
* `service/s3/s3manager`: Add Upload Buffer Provider ([aws#404](aws/aws-sdk-go-v2#404))
  * Adds a new `BufferProvider` member for specifying how part data can be buffered in memory.
  * Windows platforms will now default to buffering 1MB per part to reduce contention when uploading files.
  * Non-Windows platforms will continue to employ a non-buffering behavior.
* `service/s3/s3manager`: Add Download Buffer Provider ([aws#404](aws/aws-sdk-go-v2#404))
  * Adds a new `BufferProvider` member for specifying how part data can be buffered in memory when copying from the http response body.
  * Windows platforms will now default to buffering 1MB per part to reduce contention when downloading files.
  * Non-Windows platforms will continue to employ a non-buffering behavior.
* `service/dynamodb/dynamodbattribute`: New Encoder and Decoder Behavior for Empty Collections ([aws#401](aws/aws-sdk-go-v2#401))
  * The `Encoder` and `Decoder` types have been enhanced to support the marshaling of empty structures, maps, and slices to and from their respective DynamoDB AttributeValues.
  * This change incorporates the behavior changes introduced via a marshal option in V1 ([aws#2834](aws#2834))

### SDK Enhancements
* `internal/awsutil`: Add suppressing logging sensitive API parameters ([aws#398](aws/aws-sdk-go-v2#398))
  * Adds suppressing logging sensitive API parameters marked with the `sensitive` trait. This prevents the API type's `String` method returning a string representation of the API type with sensitive fields printed such as keys and passwords.
  * Related to [aws#2310](aws#2310)
  * Fixes [aws#251](aws/aws-sdk-go-v2#251)
* `aws/request` : Retryer is now a named field on Request. ([aws#393](aws/aws-sdk-go-v2#393))
* `service/s3/s3manager`: Adds `sync.Pool` to allow reuse of part buffers for streaming payloads ([aws#404](aws/aws-sdk-go-v2#404))
  * Fixes [aws#402](aws/aws-sdk-go-v2#402)
  * Uses the new behavior introduced in V1 [aws#2863](aws#2863) which allows the reuse of the sync.Pool across multiple Upload request that match part sizes.

### SDK Bugs
* `service/s3/s3manager`: Fix index out of range when a streaming reader returns -1 ([aws#378](aws/aws-sdk-go-v2#378))
  * Fixes the S3 Upload Manager's handling of an unbounded streaming reader that returns negative bytes read.
* `internal/ini`: Fix ini parser to handle empty values [aws#406](aws/aws-sdk-go-v2#406)
  * Fixes incorrect modifications to the previous token value of the skipper. Adds checks for cases where a skipped statement should be marked as complete and not be ignored.
  * Adds tests for nested and empty field value parsing, along with tests suggested in [aws#2801](aws#2801)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We are asking the community to submit a PR to resolve this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants