aws-cloudformation / rain

A development workflow tool for working with AWS CloudFormation.
Apache License 2.0
750 stars 69 forks source link

Add support for Claude3, an interactive build mode, and build policy files #358

Closed ericzbeard closed 2 months ago

ericzbeard commented 2 months ago

This PR enhances the rain build command. rain build --prompt now allows for model selection. Claude 3 Sonnet and Haiku are big improvements over Claude 2. We also added a fully interactive mode for build, since the number of options is starting to get complex. And you can now generate OPA Rego and CloudFormation Guard policy files by describing what you want to enforce.

hariprakash-j commented 2 months ago

this is a great addition, writing guard rules is a pain and this will be a huge help for me ! :smile:

ericzbeard commented 2 months ago

Terminal Bell During Option Selection

Yes it's super annoying and I can't find how to disable it!

null93 commented 2 months ago

@ericzbeard Looks like its a known issue with the library. Checkout https://github.com/manifoldco/promptui/issues/49#issuecomment-573814976. The comment talks about how to solve this with "bellSkipper". Its kind of hacky but if it works, it works.

As a side note, if you are looking for a pretty good TUI library consider https://github.com/charmbracelet/bubbletea. They have some pretty good components, checkout https://github.com/charmbracelet/bubbles for some example gifs.

ericzbeard commented 2 months ago

No Profile Flag

This is fixed, but -p and -r are taken by --profile and --region, so I had to remove those shortcuts from --prompt and --recommend. I think this is fine, since we have interactive mode now to make things easier and this is not likely a command that is being used in any automation that would break.

null93 commented 2 months ago

@ericzbeard Ran into another issue. Looks like I do not have access to any of the models:

raffi@mini rain % go run cmd/rain/main.go build --profile staging-management-full
✅ template: Create a CloudFormation template
✅ prompt: Use Bedrock and Claude to generate a template based on a prompt
✅ claude3sonnet: Claude 3 Sonnet
Describe the architecture you want to see in the template: Describe the architecture you want to see in the template: An autoscaling cluster with a web layer, a jump host, a varnish node, a database node, and an opensearch node.
error invoking model: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 403, RequestID: b8ef1216-bef4-43fd-a689-822832eb904c, AccessDeniedException: You don't have access to the model with the specified model ID.
exit status 1
raffi@mini rain % go run cmd/rain/main.go build --profile staging-management-full
✅ template: Create a CloudFormation template
✅ prompt: Use Bedrock and Claude to generate a template based on a prompt
✅ claude3haiku: Claude 3 Haiku
Describe the architecture you want to see in the template: Describe the architecture you want to see in the template: An autoscaling cluster with a web layer, a jump host, a varnish node, a database node, and an opensearch node.
error invoking model: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 403, RequestID: 36f4ead6-9843-484b-ac52-6e25b42ef27f, AccessDeniedException: You don't have access to the model with the specified model ID.
exit status 1
raffi@mini rain % go run cmd/rain/main.go build --profile staging-management-full
✅ template: Create a CloudFormation template
✅ prompt: Use Bedrock and Claude to generate a template based on a prompt
✅ claude2: Claude 2
Describe the architecture you want to see in the template: Describe the architecture you want to see in the template: An autoscaling cluster with a web layer, a jump host, a varnish node, a database node, and an opensearch node.
error invoking model: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 403, RequestID: d3694e75-aac2-4a0a-867b-17dc694285b4, AccessDeniedException: You don't have access to the model with the specified model ID.
exit status 1

Logged in manually and saw that I need to submit a request with a use case.

image

Is this expected? Do you want me to test this functionality out or should I just skip the prompt feature?

ericzbeard commented 2 months ago

@ericzbeard Looks like its a known issue with the library. Checkout manifoldco/promptui#49 (comment). The comment talks about how to solve this with "bellSkipper". Its kind of hacky but if it works, it works.

As a side note, if you are looking for a pretty good TUI library consider https://github.com/charmbracelet/bubbletea. They have some pretty good components, checkout https://github.com/charmbracelet/bubbles for some example gifs.

Good find! I used the solution farther down that apparently works better with Windows.

ericzbeard commented 2 months ago

@ericzbeard Ran into another issue. Looks like I do not have access to any of the models:

Is this expected? Do you want me to test this functionality out or should I just skip the prompt feature?

This is expected. You have to activate those models in your account. They are not free.

ericzbeard commented 2 months ago

Thanks @hariprakash-j and @null93 for the detailed feedback and testing! I think this is ready to merge. I will get a release out later today.

ericzbeard commented 2 months ago

The only things I would suggest changing is breaking up the build command into subcommands.

Yeah, it's getting chunky. That's why I made the interactive mode, so users won't have to decipher all the params. Next time I add anything here, I will look at a redesign.

hariprakash-j commented 2 months ago

I tested the rest of the functionality (other than the prompt feature) and it looks great! Good job!

The only things I would suggest changing is breaking up the build command into subcommands. It does not seem consistent with the rest of the cli tool. It seems like the build command does a lot of different things and it switches based on the flag you pass.

The other thing is that terminal bell. For the short time I was testing this it got on my nerves a lot lol.

+1 on making the generative features its own command, something like rain generate ?