Skip to content

Commit

Permalink
Initial commit with dependencies between stacksets
Browse files Browse the repository at this point in the history
  • Loading branch information
allcloud-sahar-hagbi committed Sep 16, 2024
1 parent a8cd80a commit 688a1a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
* and limitations under the License.
*/

import * as cdk from 'aws-cdk-lib';
import { pascalCase } from 'change-case';
import { Construct } from 'constructs';
import * as path from 'path';
import { AcceleratorKeyType, AcceleratorStack, AcceleratorStackProps } from './accelerator-stack';
import {
PortfolioAssociationConfig,
PortfolioConfig,
Expand All @@ -25,9 +20,14 @@ import {
import {
IdentityCenterGetPermissionRoleArn,
IdentityCenterGetPermissionRoleArnProvider,
SharePortfolioWithOrg,
PropagatePortfolioAssociations,
SharePortfolioWithOrg,
} from '@aws-accelerator/constructs';
import * as cdk from 'aws-cdk-lib';
import { pascalCase } from 'change-case';
import { Construct } from 'constructs';
import * as path from 'path';
import { AcceleratorKeyType, AcceleratorStack, AcceleratorStackProps } from './accelerator-stack';

export class CustomizationsStack extends AcceleratorStack {
/**
Expand Down Expand Up @@ -85,6 +85,7 @@ export class CustomizationsStack extends AcceleratorStack {
this.props.customizationsConfig?.customizations?.cloudFormationStackSets
) {
const customStackSetList = this.props.customizationsConfig.customizations.cloudFormationStackSets;

for (const stackSet of customStackSetList ?? []) {
this.logger.info(`New stack set ${stackSet.name}`);
const deploymentTargetAccounts: string[] | undefined = this.getAccountIdsFromDeploymentTargets(
Expand All @@ -95,10 +96,10 @@ export class CustomizationsStack extends AcceleratorStack {
const parameters = stackSet.parameters?.map(parameter => {
return { parameterKey: parameter.name, parameterValue: parameter.value };
});

new cdk.aws_cloudformation.CfnStackSet(
const currentStackSetId = pascalCase(`${this.props.prefixes.accelerator}-Custom-${stackSet.name}`)
let stackSetObj = new cdk.aws_cloudformation.CfnStackSet(
this,
pascalCase(`${this.props.prefixes.accelerator}-Custom-${stackSet.name}`),
currentStackSetId,
{
permissionModel: 'SELF_MANAGED',
stackSetName: stackSet.name,
Expand All @@ -121,6 +122,7 @@ export class CustomizationsStack extends AcceleratorStack {
parameters,
},
);
stackSetObj.node.addDependency(pascalCase(`${this.props.prefixes.accelerator}-Custom-${stackSetObj.dependsOn}`))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class CloudFormationStackSetConfig implements i.ICloudFormationStackSet {
readonly regions: t.Region[] = ['us-east-1'];
readonly template: string = '';
readonly parameters: t.CfnParameter[] | undefined = undefined;
readonly dependsOn: string[] = []
}

export class AlbListenerFixedResponseConfig implements i.IAlbListenerFixedResponseConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,11 @@ export interface ICloudFormationStackSet {
* The parameters to be passed to the stackset.
*/
readonly parameters?: t.ICfnParameter[];
/**
* The order to deploy the stack relative to the other stacks. Must be a positive integer.
* To deploy stacks in parallel, set runOrder of each stack to 1.
*/
readonly dependsOn: string[];
}

export type PortfolioAssociationType = 'User' | 'Group' | 'Role' | 'PermissionSet';
Expand Down

0 comments on commit 688a1a6

Please sign in to comment.