question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(servicecatalog): Optional fields for `CloudFormationProduct` do not synth in template for python

See original GitHub issue

What is the problem?

According to the generated docs for python (and also the analogous ts experience) , we should be able to create a product like so:

# Example automatically generated. See https://github.com/aws/jsii/issues/826
product = servicecatalog.CloudFormationProduct(self, "MyFirstProduct",
    product_name="My Product",
    owner="Product Owner",
    product_versions=[{
        "product_version_name": "v1",
        "cloud_formation_template": servicecatalog.CloudFormationTemplate.from_url("https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/ServiceCatalog/Product.yaml")
    }
    ]
)

The product_versions field takes a list of these dict objects. The fields product_version_name and product_version_description are both optional. However, if even if you include them they do not appear in the synthed template:

      ProvisioningArtifactParameters:
          DisableTemplateValidation: false
          Info:
            LoadTemplateFromURL: https://www.google.com

Somehow in these fields being optional they are getting cast to None somewhere. There is a workaround which is to initialize background class CloudFormationProductVersion directly like so:

product_versions=[
  sc.CloudFormationProductVersion(
    cloud_formation_template = sc.CloudFormationTemplate.from_url('https://www.example.com/file.yaml'),
    product_version_name = 'test',
    description = 'test_description',
  ),
]

Need to figure out why the optional fields are somehow being discarded from the template so that passing in fields works as expected.

Reproduction Steps

Included above, but copy from the README example:

# Example automatically generated. See https://github.com/aws/jsii/issues/826
product = servicecatalog.CloudFormationProduct(self, "MyFirstProduct",
    product_name="My Product",
    owner="Product Owner",
    product_versions=[{
        "product_version_name": "v1",
        "cloudFormationTemplate": servicecatalog.CloudFormationTemplate.from_url("https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/ServiceCatalog/Product.yaml")
    }]
)

Will not include the name field in template

What did you expect to happen?

Expected product_version_name and product_version_description fields to be reflected in the generated template

What actually happened?

The fields did not generate in the template at all.

CDK CLI Version

1.130.0

Framework Version

No response

Node.js Version

12.22.3

OS

Mac

Language

Python

Language Version

3.7

Other information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
arcrankcommented, Dec 15, 2021

Yeah we can close this, the newer docs have correct syntax.

0reactions
github-actions[bot]commented, Dec 15, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-servicecatalog module - AWS Documentation
You can create a Service Catalog CloudFormationProduct entirely defined with CDK code ... 'description for topic2', // description is an optional field. });....
Read more >
AWS::ServiceCatalog::CloudFormationProduct ... - 亚马逊云科技
Information about a provisioning artifact (also known as a version) for a product. Syntax. To declare this entity in your Amazon CloudFormation template,...
Read more >
What is AWS CDK and How it Works? - SJ Innovation
CDK stands for Cloud development Kit and is a tool from AWS cloud services to write infrastructure as code. ... You don't have...
Read more >
aws-cdk | Yarn - Package Manager
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through...
Read more >
aws-cdk.aws-servicecatalog - PyDigger
```python import aws_cdk.aws_servicecatalog as servicecatalog ... Using the CDK, if you do not explicitly associate a product to a portfolio and add a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found