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

In the KMS generator config define a custom error for NotFoundException + regenerate code #659

Merged
merged 1 commit into from May 24, 2021

Conversation

bandesz
Copy link
Contributor

@bandesz bandesz commented May 10, 2021

Description of your changes

The KMS Key resource is broken and you can't create a KMS key with it. Fixes: #647

After looking at the code it seems the IsNotFound() function was generated incorrectly:

https://github.com/crossplane/provider-aws/blob/1ad7872a1b8f19cbd56f020e780ee698198163dc/pkg/controller/kms/key/zz_conversions.go#L147

I added a custom exception to the generator config. Although the API returns a 400 http code if the kms key does not exist, I still had to use 404 in the config, which seemed to do the trick.

I followed the instructions from CODE_GENERATION.md and ran these two commands:

In code-generator:

go run -tags codegen cmd/ack-generate/main.go crossplane kms --provider-dir /.../src/github.com/crossplane/provider-aws

In provider-aws:

make generate

I'm not sure I generated the code correctly as there are more changes that I would expect.

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

I've built and deployed the provider to a real environment and tested KMS key creation, with and without an external-name.

…on + regenerate code

In the API this is a 400 error, but we have to define it as a 404 error in the config,
so the IsNotFound() function is generated correctly

Signed-off-by: bandesz <andras.ferencz-szabo@appvia.io>
@bandesz bandesz changed the title [WIP] In the KMS generator config define a custom error for NotFoundException + regenerate code In the KMS generator config define a custom error for NotFoundException + regenerate code May 11, 2021
Copy link
Member

@muvaf muvaf left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @bandesz !

@muvaf muvaf merged commit 2eed9f3 into crossplane-contrib:master May 24, 2021
tektondeploy pushed a commit to gtn3010/provider-aws that referenced this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key (kms.aws.crossplane.io) is not creating new resources
2 participants