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: Expose a parameters property in StackSet construct #447

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const stack = new Stack();
const stackSetStack = new StackSetStack(stack, 'MyStackSet');

new StackSet(stack, 'StackSet', {
parameters: {
SomeParam: 'Value',
},
target: StackSetTarget.fromAccounts({
regions: ['us-east-1'],
accounts: ['11111111111'],
parameterOverrides: {
SomeParam: 'overrideValue',
},
}),
template: StackSetTemplate.fromStackSetStack(stackSetStack),
});
Expand Down
24 changes: 21 additions & 3 deletions src/stackset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ interface StackSetTargetConfig {
readonly organizationalUnits?: string[];
}

interface TargetBindOptions {}
interface TargetBindOptions {
}

/**
* Which organizational units and/or accounts the stack set
Expand Down Expand Up @@ -346,7 +347,8 @@ interface DeploymentTypeConfig {
readonly callAs?: CallAs;
}

interface DeploymentTypeOptions {}
interface DeploymentTypeOptions {
}

export abstract class DeploymentType {
/**
Expand Down Expand Up @@ -475,6 +477,11 @@ export interface StackSetProps {
*/
readonly operationPreferences?: OperationPreferences;

/**
* The input parameters for the stack set template.
*/
readonly parameters?: StackSetParameter;

/**
* Specify a list of capabilities required by your stackset.
*
Expand Down Expand Up @@ -607,6 +614,7 @@ export class StackSet extends Resource implements IStackSet {

private readonly _role?: iam.IRole;
private readonly permissionModel: PermissionModel;

constructor(scope: Construct, id: string, props: StackSetProps) {
super(scope, id, {
physicalName: props.stackSetName ?? Lazy.string({ produce: () => Names.uniqueResourceName(this, {}) }),
Expand Down Expand Up @@ -655,7 +663,17 @@ export class StackSet extends Resource implements IStackSet {
permissionModel: deploymentTypeConfig.permissionsModel,
callAs: deploymentTypeConfig.callAs,
templateUrl: props.template.templateUrl,
stackInstancesGroup: Lazy.any({ produce: () => { return this.stackInstances; } }),
stackInstancesGroup: Lazy.any({
produce: () => {
return this.stackInstances;
},
}),
parameters: props.parameters ? Object.entries(props.parameters).map((entry) => {
return {
parameterKey: entry[0],
parameterValue: entry[1],
};
}) : undefined,
});

// the file asset bucket deployment needs to complete before the stackset can deploy
Expand Down
10 changes: 7 additions & 3 deletions test/stack-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ test('default', () => {
target: StackSetTarget.fromAccounts({
regions: ['us-east-1'],
accounts: ['11111111111'],
parameterOverrides: {
Param1: 'Value1',
},
}),
template: StackSetTemplate.fromStackSetStack(new StackSetStack(stack, 'Stack')),
parameters: {
Param1: 'Value1',
},
});

Template.fromStack(stack).hasResourceProperties('AWS::CloudFormation::StackSet', {
Expand All @@ -48,6 +48,10 @@ test('default', () => {
TemplateURL: {
'Fn::Sub': 'https://s3.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a.json',
},
Parameters: [{
ParameterKey: 'Param1',
ParameterValue: 'Value1',
}],
StackInstancesGroup: [{
Regions: ['us-east-1'],
DeploymentTargets: {
Expand Down