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

CloudFormation Schema Issues #300

Closed
PaulMaddox opened this issue Aug 25, 2020 · 4 comments
Closed

CloudFormation Schema Issues #300

PaulMaddox opened this issue Aug 25, 2020 · 4 comments

Comments

@PaulMaddox
Copy link
Contributor

PaulMaddox commented Aug 25, 2020

The latest CloudFormation schema published (2020-08-25) has two issues:

AWS::ECR::Repository.RepositoryPolicyText has no PrimiviteType (or any type).
AWS::KMS::Key.KeyPolicy has no PrimitiveType (or any type).

"AWS::ECR::Repository": {
  "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html",
  "Properties": {
    "RepositoryPolicyText": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-repositorypolicytext",
      "UpdateType": "Mutable",
      "Required": false
    },
"AWS::KMS::Key": {
  "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html",
  "Properties": {
    "KeyPolicy": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy",
      "UpdateType": "Mutable",
      "Required": true
    },

source: https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json

This causes tests to fail after code generation:

❯ go test ./...
# github.com/awslabs/goformation/v4/cloudformation/ecr
cloudformation/ecr/aws-ecr-repository.go:39:24: undefined: Repository_
# github.com/awslabs/goformation/v4/cloudformation/kms
cloudformation/kms/aws-kms-key.go:34:13: undefined: Key_

Ticket raised with CloudFormation team to have this corrected.

PaulMaddox added a commit to PaulMaddox/goformation that referenced this issue Aug 25, 2020
If the CloudFormation Resource Specification has a resource property
that does not include any type information then this should be a
breaking error and generation should fail.

See awslabs#300
PaulMaddox added a commit that referenced this issue Aug 25, 2020
* Check for properties with no type in CFN spec

If the CloudFormation Resource Specification has a resource property
that does not include any type information then this should be a
breaking error and generation should fail.

See #300
ndeloof added a commit to ndeloof/goformation that referenced this issue Aug 27, 2020
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
PaulMaddox added a commit that referenced this issue Oct 11, 2020
If a resource property is missing a type in the CloudFormation Resource
Specification (see #300), then autofix it to type = 'Json', which will
in turn set it to interface{} in the generated Go structs.

Do this instead of blocking all builds on missing type information.
PaulMaddox added a commit that referenced this issue Oct 11, 2020
* fix(generator): autofix missing property types

If a resource property is missing a type in the CloudFormation Resource
Specification (see #300), then autofix it to type = 'Json', which will
in turn set it to interface{} in the generated Go structs.

Do this instead of blocking all builds on missing type information.

* chore(ci): allow manual trigger of schema update
@PaulMaddox
Copy link
Contributor Author

This still has not been resolved upstream in the CloudFormation Resource Specification.

I have put in place a workaround in #314. Instead of blocking resource generation when properties are found with missing type information, we instead set the type to Json. This in turn will set the property type to interface{} in the generated Go structs.

This is an example of the output where the autofixing is logged:

❯ go generate
GoFormation Resource Generator
Downloading cloudformation specification from https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json
Warning: auto-fixing missing property type to 'Json' for http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy
Warning: auto-fixing missing property type to 'Json' for http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-repositorypolicytext

@xrn
Copy link
Contributor

xrn commented Jul 18, 2022

@rubenfonseca I believe this is solved as well all resources have PrimitiveType

@rubenfonseca
Copy link
Contributor

Thanks!

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

No branches or pull requests

4 participants