Skip to content

Commit

Permalink
fixing last commit that deleted file instead of unstaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Crank committed Jul 30, 2021
1 parent a586aa8 commit 32a7200
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-servicecatalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enables organizations to create and manage catalogs of products for their end us
- [Constraints](#constraints)
- [Tag update constraint](#tag-update-constraint)
- [Notify on stack events](#notify-on-stack-events)
- [Cloudformation parameters constraint](#cloudformation-parameters-constraint)
- [CloudFormation parameters constraint](#cloudformation-parameters-constraint)
- [Set launch role](#set-launch-role)
- [Deploy with StackSets](#deploy-with-stacksets)

Expand Down Expand Up @@ -229,7 +229,7 @@ portfolio.notifyOnStackEvents(product, topic2, {
});
```

### Cloudformation parameters constraint
### CloudFormation parameters constraint

Allows you to configure the options that are available to end users when they launch a product.
A provisioning rule consists of one or more assertions that narrow the allowable values for parameters in a product.
Expand All @@ -244,7 +244,7 @@ see [AWS Rule Functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/Us
import * as cdk from '@aws-cdk/core';

portfolio.constrainCloudFormationParameters(product, {
assertion: {
rule: {
ruleName: 'testInstanceType',
condition: cdk.Fn.conditionEquals(cdk.Fn.ref('Environment'), 'test'),
assertions: [{
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-servicecatalog/lib/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface TemplateRuleAssertion {
readonly assert: cdk.ICfnRuleConditionExpression;

/**
* The description for the asssertion
* The description for the asssertion.
* @default - no description provided for the assertion.
*/
readonly description?: string;
Expand All @@ -92,7 +92,7 @@ export interface TemplateRule {

/**
* Specify when to apply rule with a rule-specific intrinsic function.
* @default - No rule condition provided.
* @default - no rule condition provided
*/
readonly condition?: cdk.ICfnRuleConditionExpression;

Expand All @@ -105,7 +105,7 @@ export interface TemplateRule {
/**
* Properties for provisoning rule constraint.
*/
export interface ProvisioningRuleOptions extends CommonConstraintOptions {
export interface CloudFormationRuleConstraintOptions extends CommonConstraintOptions {
/**
* The rule with condition and assertions to apply to template.
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as sns from '@aws-cdk/aws-sns';
import * as cdk from '@aws-cdk/core';
import { MessageLanguage } from './common';
import {
CommonConstraintOptions, StackSetsConstraintOptions,
TagUpdateConstraintOptions, ProvisioningRuleOptions,
CloudFormationRuleConstraintOptions, CommonConstraintOptions,
StackSetsConstraintOptions, TagUpdateConstraintOptions,
} from './constraints';
import { AssociationManager } from './private/association-manager';
import { hashValues } from './private/util';
Expand Down Expand Up @@ -108,7 +108,7 @@ export interface IPortfolio extends cdk.IResource {
* @param product A service catalog product.
* @param options options for the constraint.
*/
constrainCloudFormationParameters(product:IProduct, options: ProvisioningRuleOptions): void;
constrainCloudFormationParameters(product:IProduct, options: CloudFormationRuleConstraintOptions): void;

/**
* Force users to assume a certain role when launching a product.
Expand Down Expand Up @@ -146,7 +146,7 @@ abstract class PortfolioBase extends cdk.Resource implements IPortfolio {
}

public addProduct(product: IProduct): void {
AssociationManager.associateProductWithPortfolio(this, product);
AssociationManager.associateProductWithPortfolio(this, product, undefined);
}

public shareWithAccount(accountId: string, options: PortfolioShareOptions = {}): void {
Expand All @@ -171,7 +171,7 @@ abstract class PortfolioBase extends cdk.Resource implements IPortfolio {
AssociationManager.notifyOnStackEvents(this, product, topic, options);
}

public constrainCloudFormationParameters(product: IProduct, options: ProvisioningRuleOptions): void {
public constrainCloudFormationParameters(product: IProduct, options: CloudFormationRuleConstraintOptions): void {
AssociationManager.constrainCloudFormationParameters(this, product, options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as iam from '@aws-cdk/aws-iam';
import * as sns from '@aws-cdk/aws-sns';
import * as cdk from '@aws-cdk/core';
import {
CommonConstraintOptions, ProvisioningRuleOptions, StackSetsConstraintOptions,
CloudFormationRuleConstraintOptions, CommonConstraintOptions, StackSetsConstraintOptions,
TagUpdateConstraintOptions, TemplateRule, TemplateRuleAssertion,
} from '../constraints';
import { IPortfolio } from '../portfolio';
Expand All @@ -17,7 +17,7 @@ import { InputValidator } from './validation';

export class AssociationManager {
public static associateProductWithPortfolio(
portfolio: IPortfolio, product: IProduct, options?: CommonConstraintOptions,
portfolio: IPortfolio, product: IProduct, options: CommonConstraintOptions | undefined,
): { associationKey: string, cfnPortfolioProductAssociation: CfnPortfolioProductAssociation } {
InputValidator.validateLength(this.prettyPrintAssociation(portfolio, product), 'description', 0, 2000, options?.description);
const associationKey = hashValues(portfolio.node.addr, product.node.addr, product.stack.node.addr);
Expand All @@ -37,7 +37,7 @@ export class AssociationManager {
}

public static constrainTagUpdates(portfolio: IPortfolio, product: IProduct, options: TagUpdateConstraintOptions): void {
const association = this.associateProductWithPortfolio(portfolio, product);
const association = this.associateProductWithPortfolio(portfolio, product, options);
const constructId = `ResourceUpdateConstraint${association.associationKey}`;

if (!portfolio.node.tryFindChild(constructId)) {
Expand All @@ -57,7 +57,7 @@ export class AssociationManager {
}

public static notifyOnStackEvents(portfolio: IPortfolio, product: IProduct, topic: sns.ITopic, options: CommonConstraintOptions): void {
const association = this.associateProductWithPortfolio(portfolio, product);
const association = this.associateProductWithPortfolio(portfolio, product, options);
const constructId = `LaunchNotificationConstraint${hashValues(topic.node.addr, topic.stack.node.addr, association.associationKey)}`;

if (!portfolio.node.tryFindChild(constructId)) {
Expand All @@ -78,9 +78,9 @@ export class AssociationManager {

public static constrainCloudFormationParameters(
portfolio: IPortfolio, product: IProduct,
options: ProvisioningRuleOptions,
options: CloudFormationRuleConstraintOptions,
): void {
const association = this.associateProductWithPortfolio(portfolio, product);
const association = this.associateProductWithPortfolio(portfolio, product, options);
const constructId = `LaunchTemplateConstraint${hashValues(association.associationKey, options.rule.ruleName)}`;

if (!portfolio.node.tryFindChild(constructId)) {
Expand All @@ -100,7 +100,7 @@ export class AssociationManager {
}

public static setLaunchRole(portfolio: IPortfolio, product: IProduct, launchRole: iam.IRole, options: CommonConstraintOptions): void {
const association = this.associateProductWithPortfolio(portfolio, product);
const association = this.associateProductWithPortfolio(portfolio, product, options);
// Check if a stackset deployment constraint has already been configured.
if (portfolio.node.tryFindChild(this.stackSetConstraintLogicalId(association.associationKey))) {
throw new Error(`Cannot set launch role when a StackSet rule is already defined for association ${this.prettyPrintAssociation(portfolio, product)}`);
Expand All @@ -124,7 +124,7 @@ export class AssociationManager {
}

public static deployWithStackSets(portfolio: IPortfolio, product: IProduct, options: StackSetsConstraintOptions) {
const association = this.associateProductWithPortfolio(portfolio, product);
const association = this.associateProductWithPortfolio(portfolio, product, options);
// Check if a launch role has already been set.
if (portfolio.node.tryFindChild(this.launchRoleConstraintLogicalId(association.associationKey))) {
throw new Error(`Cannot configure StackSet deployment when a launch role is already defined for association ${this.prettyPrintAssociation(portfolio, product)}`);
Expand Down Expand Up @@ -209,7 +209,7 @@ export class AssociationManager {
AssertDescription: assertion.description,
});
return formattedAssertions;
}, Array<{ Assert: string, AssertDescription: string | undefined }>());
}, new Array<{ Assert: string, AssertDescription: string | undefined }>());
};
}

4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-servicecatalog/test/integ.portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ portfolio.constrainCloudFormationParameters(product, {
rule: {
ruleName: 'SubnetsinVPC',
assertions: [{
assert: cdk.Fn.conditionEachMemberIn(cdk.Fn.valueOfAll('AWs::EC2::Subnet::Id', 'VpcId'), cdk.Fn.refAll('AWS::EC2::VPC::Id')),
assert: cdk.Fn.conditionEachMemberIn(
cdk.Fn.valueOfAll('AWs::EC2::Subnet::Id', 'VpcId'),
cdk.Fn.refAll('AWS::EC2::VPC::Id')),
description: 'test description',
}],
},
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-servicecatalog/test/portfolio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ describe('portfolio associations and product constraints', () => {
}).toThrowError(`Topic ${topic} is already subscribed to association`);
}),

test('set provisioning rule', () => {
test('creates a CloudFormation parameters constraint', () => {
portfolio.addProduct(product);
portfolio.constrainCloudFormationParameters(product, {
rule: {
Expand Down Expand Up @@ -489,7 +489,7 @@ describe('portfolio associations and product constraints', () => {
});
}),

test('set provisioning rule still creates without explicit association', () => {
test('CloudFormation parameters constraint still creates without explicit association', () => {
portfolio.constrainCloudFormationParameters(product, {
rule: {
ruleName: 'Rule',
Expand All @@ -508,7 +508,7 @@ describe('portfolio associations and product constraints', () => {
expect(stack).toHaveResourceLike('AWS::ServiceCatalog::LaunchTemplateConstraint');
}),

test('set multiple provisioning rules', () => {
test('set multiple CloudFormation parameters constraints', () => {
portfolio.constrainCloudFormationParameters(product, {
rule: {
ruleName: 'Rule01',
Expand All @@ -532,7 +532,7 @@ describe('portfolio associations and product constraints', () => {
expect(stack).toCountResources('AWS::ServiceCatalog::LaunchTemplateConstraint', 2);
}),

test('fails to set a duplicate provisioning rule', () => {
test('fails to set a duplicate CloudFormation parameters constraint', () => {
portfolio.constrainCloudFormationParameters(product, {
rule: {
ruleName: 'Rule01',
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/core/lib/cfn-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export interface ICfnConditionExpression extends IResolvable {}
*/
export interface ICfnRuleConditionExpression extends ICfnConditionExpression {
/**
* This field is here for typing service catalog rule specific intrinsic functions.
* This field is only needed to defeat TypeScript's structural typing.
* It is never used.
*/
readonly disambiguator: boolean;
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/cfn-fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ class FnCidr extends FnBase {
}

class FnConditionBase extends Intrinsic implements ICfnRuleConditionExpression {
readonly disambiguator: boolean = true;
readonly disambiguator = true;
constructor(type: string, value: any) {
super({ [type]: value });
}
Expand Down

0 comments on commit 32a7200

Please sign in to comment.