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

Rewrite the build command to use registry schemas instead of spec files #262

Merged
merged 16 commits into from
Jan 29, 2024

Conversation

ericzbeard
Copy link
Contributor

@ericzbeard ericzbeard commented Jan 24, 2024

This is a breaking change to the way the build command works. Instead of using a locally stored copy of the spec file, we now download the current schema from the registry in your account/region. In some ways this will be more accurate, since the registry schemas are more expressive and represent the source of truth going forward. But registry coverage is not yet 100%, so some resources will not build correctly. I added a patching mechanism so that we can improve the output when the schemas are lacking.

SAM templates used to be generated based on parsing documentation files, which are no longer maintained, so we switched to parsing a simplified SAM schema from the goformation project and converting it into the registry schema format.

@ericzbeard ericzbeard marked this pull request as ready for review January 26, 2024 17:50
@ericzbeard
Copy link
Contributor Author

ericzbeard commented Jan 26, 2024

@hariprakash-j, @khmoryz, @null93, @iainelder Please let me know what you think of this when you have time. I'm honestly not even sure how many people use the build command. This will require a major version bump to be safe. I'd like to expand this command in the future so that it will output hand-crafted templates that follow best practices and pass compliance checks by default, maybe with a --recommended flag.

@ericzbeard ericzbeard added enhancement New feature or request breaking-change This PR will require a major version bump labels Jan 26, 2024
@khmoryz
Copy link
Collaborator

khmoryz commented Jan 28, 2024

Hi @ericzbeard

I think your improvement is great.
Template correctness is more important than coverage.

I use rain build as usual. However, I don't remember all of the aws resource types, so I often do a fuzzy search on google.com and copy the templates from docs.aws.amazon.com.

I think major version upgrade is not a problem, because I don't think rain build is used in automation.

As for the --recommended flag, it is great.
But, I have concerns about continuing maintenance.

@null93
Copy link
Collaborator

null93 commented Jan 28, 2024

I cannot speak too much on this because I don't use the build command. I just refer to the docs. I can see it being more useful to me if it had more detailed information like the docs do.

If this PR makes the output more accurate, I think that is great!

@ericzbeard ericzbeard merged commit 4e5851e into aws-cloudformation:main Jan 29, 2024
1 check passed
@ericzbeard ericzbeard deleted the schema branch January 29, 2024 22:47
@ericzbeard ericzbeard mentioned this pull request Jan 29, 2024
@iainelder
Copy link

Just catching up now after an extended break from GitHub.

I don't use the rain build command. Like @null93 , I read the docs and type the templates by hand in VS Code.

Can I use the feature to write correct templates more quickly?

@ericzbeard
Copy link
Contributor Author

Can I use the feature to write correct templates more quickly?

Yes, and I just added a new feature to the build command to emit fully functional, tested templates for certain use cases. It's not released yet so you would need to install from @main. So there are now 3 modes for build:

  • Default mode with a resource type like AWS::S3::Bucket, which spits out all properties with placeholders like STRING for values.
  • LLM Prompt mode, for example, rain build -p 'A vpc with 2 subnets'
  • Recommendations, fully tested templates. rain build -r

@iainelder
Copy link

iainelder commented Feb 27, 2024

Sounds awesome!

For a VS Code user, what does the workflow look like?

I'm thinking:

  • Run rain build ResourceType in a terminal and copy the output
  • Paste the output into my template editor tab
  • Edit the output to change the placeholders and delete optional properties where the default is fine.

A way to use the template generation from inside VS Code would be awesome too. Maybe out of scope for this repo, but another repo with an extension for VS Code could handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This PR will require a major version bump enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants