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

feat(servicecatalog): add CloudFormation Parameter constraint #15770

Merged
merged 19 commits into from
Jul 30, 2021

Conversation

arcrank
Copy link
Contributor

@arcrank arcrank commented Jul 26, 2021

Add ability to configure parameter options for when launching a product.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Co-authored-by: Dillon Ponzo dponzo18@gmail.com

Add ability to configure parameter options for when launching a product.

Co-authored-by: Dillon Ponzo <dponzo18@gmail.com>
@gitpod-io
Copy link

gitpod-io bot commented Jul 26, 2021

@arcrank
Copy link
Contributor Author

arcrank commented Jul 26, 2021

Want to specifically call out how we call the formatRules in association-manager.ts to make sure that that approach is cdk friendly. Seemed like a clean way to do it in typescript but please let us know if there is another avenue that you think is better.

Also scoping down the types for the Cfn Conditions proved more cumbersome than just using the condition interface and adding documentation about what intrinsic functions you can use.

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Want to specifically call out how we call the formatRules in association-manager.ts to make sure that that approach is cdk friendly. Seemed like a clean way to do it in typescript but please let us know if there is another avenue that you think is better.

I think it's fine... what specifically were you worried about?

Also scoping down the types for the Cfn Conditions proved more cumbersome than just using the condition interface and adding documentation about what intrinsic functions you can use.

Can you expand why was it cumbersome? I still would like to see this change implemented, so that specifying the wrong function will be a compile-time error.

packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts Outdated Show resolved Hide resolved
// Add dependsOn to force proper order in deployment.
constraint.addDependsOn(association.cfnPortfolioProductAssociation);
} else {
throw new Error(`Provisioning rule ${assertion.ruleName} already configured on association ${this.prettyPrintAssociation(portfolio, product)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

There's some thought to making this override the previous Rule, instead of erroring out.

Maybe an option in constrainProvisioningParameters?

Copy link
Contributor Author

@arcrank arcrank Jul 27, 2021

Choose a reason for hiding this comment

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

This is here because in CFN templates you would have all the provisioning rules listed in the same construct, so you can't have overlapping names which are the keys in the map. I broke it apart here like the event notifications, since one would probably only ever add 1-2 rules per product, but I think we still would rather keep unique names in case we need to shift back to that mode of adding all rules in one construct, which would be less of a breaking change if we enforce unique names now. But I don't think someone would want to override rules, usually they would do that with the condition.

packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts Outdated Show resolved Hide resolved
@arcrank
Copy link
Contributor Author

arcrank commented Jul 27, 2021

Can you expand why was it cumbersome? I still would like to see this change implemented, so that specifying the wrong function will be a compile-time error.

I meant it was going to be cumbersome to fit in this PR. We have been looking at how to modify the interface in core for these to extend a ICfnRuleConditionExpression that can extend the current ICfnConditionExpression but will take some time.

@mergify mergify bot dismissed skinny85’s stale review July 27, 2021 16:46

Pull request has been modified.

@arcrank arcrank requested a review from skinny85 July 27, 2021 16:47
@skinny85
Copy link
Contributor

Can you expand why was it cumbersome? I still would like to see this change implemented, so that specifying the wrong function will be a compile-time error.

I meant it was going to be cumbersome to fit in this PR. We have been looking at how to modify the interface in core for these to extend a ICfnRuleConditionExpression that can extend the current ICfnConditionExpression but will take some time.

Fortunately, you made this PR small enough that I don't think adding the changes in core to it will make it too big 😉.

Please include these in this PR.

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Looks good overall, but please include the changes mentioned in #15770 (comment) to make providing the functions to the assertions compile-time safe.

packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
@@ -7,4 +7,4 @@ export function hashValues(...ids: string[]): string {
const sha256 = crypto.createHash('sha256');
ids.forEach(val => sha256.update(val));
return sha256.digest('hex').slice(0, 12);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what/how this snuck in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still here 😉.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

didn't see what change was but I think this is removed now

@arcrank arcrank force-pushed the add_provisioning_rules branch from bffb25f to c927a18 Compare July 28, 2021 00:12
@mergify mergify bot dismissed skinny85’s stale review July 28, 2021 00:13

Pull request has been modified.

@arcrank
Copy link
Contributor Author

arcrank commented Jul 28, 2021

I am still not sure if this is correct way for implementing the stronger typed assertions, I am still not sure if this is correct, it almost looks like the already existing ICfnConditionExpression is used where we need it.... still digging.

Edit: Actually I am not sure what exactly the issue was, I think ICfnConditionExpression is the rule conditions we want. Was there a different example of this working where it shouldn't?

@peterwoodworth peterwoodworth added the @aws-cdk/aws-servicecatalog Related to AWS Service Catalog label Jul 28, 2021
* Interface to specify certain functions as rule-specifc.
* These functions can only be used in ``Rules`` section of template.
*/
export interface ICfnRuleConditionExpression extends ICfnConditionExpression {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this

@arcrank arcrank force-pushed the add_provisioning_rules branch from 71d4a3f to 28c6369 Compare July 29, 2021 21:26
@arcrank arcrank requested a review from skinny85 July 29, 2021 21:51
@arcrank
Copy link
Contributor Author

arcrank commented Jul 29, 2021

I might've requested review too early, I thought build failed after making CfnRule change but that might have been from master branch being out of date, rebuilding.

@arcrank arcrank force-pushed the add_provisioning_rules branch from 091631a to a586aa8 Compare July 29, 2021 22:19
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Looks great! A few minor notes.

packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts Outdated Show resolved Hide resolved
@@ -7,4 +7,4 @@ export function hashValues(...ids: string[]): string {
const sha256 = crypto.createHash('sha256');
ids.forEach(val => sha256.update(val));
return sha256.digest('hex').slice(0, 12);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Still here 😉.

packages/@aws-cdk/core/lib/cfn-condition.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/core/lib/cfn-fn.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed skinny85’s stale review July 30, 2021 00:52

Pull request has been modified.

@arcrank arcrank force-pushed the add_provisioning_rules branch from f64a78a to 32a7200 Compare July 30, 2021 01:06
@arcrank arcrank force-pushed the add_provisioning_rules branch from 8e73ae6 to 8cc8d28 Compare July 30, 2021 01:41
@arcrank arcrank force-pushed the add_provisioning_rules branch from b9d6d15 to f3887ba Compare July 30, 2021 03:09
@arcrank
Copy link
Contributor Author

arcrank commented Jul 30, 2021

Okay, I tried Codebuild with and without the changes in cfn-rule.ts since I kept getting build errors. I am pretty sure I've had updates from master, is there a better way to do it? I also fetched upstream in my local branch and did build and test in both servicecatalog and core.

@skinny85
Copy link
Contributor

Okay, I tried Codebuild with and without the changes in cfn-rule.ts since I kept getting build errors. I am pretty sure I've had updates from master, is there a better way to do it? I also fetched upstream in my local branch and did build and test in both servicecatalog and core.

Like I suspected, you need to revert the changes to CfnRule:

@aws-cdk/core... CHANGES.
Original assembly: @aws-cdk/core@1.116.0
Updated assembly:  @aws-cdk/core@0.0.0
API elements with incompatible changes:
err  - METHOD @aws-cdk/core.CfnRule.addAssertion: argument condition, takes @aws-cdk/core.ICfnRuleConditionExpression (formerly @aws-cdk/core.ICfnConditionExpression): @aws-cdk/core.ICfnConditionExpression does not extend @aws-cdk/core.ICfnRuleConditionExpression [incompatible-argument:@aws-cdk/core.CfnRule.addAssertion]
err  - IFACE @aws-cdk/core.CfnRuleAssertion: property assert, @aws-cdk/core.ICfnConditionExpression does not extend @aws-cdk/core.ICfnRuleConditionExpression: type of property assertions, input to @aws-cdk/core.CfnRule.<initializer> [strengthened:@aws-cdk/core.CfnRuleAssertion]
err  - IFACE @aws-cdk/core.CfnRuleProps: property ruleCondition, @aws-cdk/core.ICfnConditionExpression does not extend @aws-cdk/core.ICfnRuleConditionExpression: input to @aws-cdk/core.CfnRule.<initializer> [strengthened:@aws-cdk/core.CfnRuleProps]

@arcrank arcrank requested a review from skinny85 July 30, 2021 19:04
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -228,6 +229,32 @@ portfolio.notifyOnStackEvents(product, topic2, {
});
```

### CloudFormation parameters constraint

CloudFormation parameters constraints allow you to configure the that are available to end users when they launch a product via defined rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing word?

Suggested change
CloudFormation parameters constraints allow you to configure the that are available to end users when they launch a product via defined rules.
CloudFormation parameters constraints allow you to configure the values that are available to end users when they launch a product via defined rules.

@@ -604,7 +604,8 @@ class FnCidr extends FnBase {
}
}

class FnConditionBase extends Intrinsic implements ICfnConditionExpression {
class FnConditionBase extends Intrinsic implements ICfnRuleConditionExpression {
readonly disambiguator = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe an empty line after this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will track for next PR.

@mergify
Copy link
Contributor

mergify bot commented Jul 30, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@skinny85 skinny85 changed the title feat(servicecatalog): Add provisioning parameters constraint feat(servicecatalog): add CloudFormation Parameter constraint Jul 30, 2021
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 8edf43a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 58fda91 into aws:master Jul 30, 2021
@mergify
Copy link
Contributor

mergify bot commented Jul 30, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Aug 3, 2021
)

Add ability to configure parameter options for when launching a product.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


Co-authored-by: Dillon Ponzo <dponzo18@gmail.com>
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
)

Add ability to configure parameter options for when launching a product.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


Co-authored-by: Dillon Ponzo <dponzo18@gmail.com>
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this pull request Sep 7, 2021
)

Add ability to configure parameter options for when launching a product.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


Co-authored-by: Dillon Ponzo <dponzo18@gmail.com>
@arcrank arcrank deleted the add_provisioning_rules branch October 25, 2021 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-servicecatalog Related to AWS Service Catalog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants