Skip to content

Commit

Permalink
fix: cdk remove-task uses --force instead of --require-approval=never
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafConijn committed Nov 22, 2023
1 parent 3fcbfc2 commit bafe5f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-organization-formation",
"version": "1.0.12-beta.2",
"version": "1.0.12-beta.4",
"description": "Infrastructure as code solution for AWS Organizations",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions src/plugin/impl/cdk-build-task-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CdkBuildTaskPlugin implements IBuildTaskPlugin<ICdkBuildTaskConfig,

Validator.ThrowForUnknownAttribute(config, config.LogicalName, ...CommonTaskAttributeNames, 'Path',
'FilePath', 'RunNpmInstall', 'RunNpmBuild', 'FailedTaskTolerance', 'MaxConcurrentTasks',
'AdditionalCdkArguments', 'InstallCommand', 'CustomDeployCommand', 'CustomRemoveCommand', 'Parameters','IgnoreFileChanges');
'AdditionalCdkArguments', 'InstallCommand', 'CustomDeployCommand', 'CustomRemoveCommand', 'Parameters', 'IgnoreFileChanges');

if (!config.Path) {
throw new OrgFormationError(`task ${config.LogicalName} does not have required attribute Path`);
Expand Down Expand Up @@ -109,7 +109,7 @@ export class CdkBuildTaskPlugin implements IBuildTaskPlugin<ICdkBuildTaskConfig,

async performCreateOrUpdate(binding: IPluginBinding<ICdkTask>, resolver: CfnExpressionResolver): Promise<void> {

const {task, target, previousBindingLocalHash } = binding;
const { task, target, previousBindingLocalHash } = binding;
if (task.forceDeploy !== true &&
task.taskLocalHash !== undefined &&
task.taskLocalHash === previousBindingLocalHash) {
Expand Down Expand Up @@ -154,7 +154,7 @@ export class CdkBuildTaskPlugin implements IBuildTaskPlugin<ICdkBuildTaskConfig,
Validator.throwForUnresolvedExpressions(task.customRemoveCommand, 'CustomRemoveCommand');
command = task.customRemoveCommand as string;
} else {
const commandExpression = { 'Fn::Sub': 'npx cdk destroy --all --require-approval=never ${CurrentTask.Parameters}' } as ICfnSubExpression;
const commandExpression = { 'Fn::Sub': 'npx cdk destroy --all --force ${CurrentTask.Parameters}' } as ICfnSubExpression;
command = await resolver.resolveSingleExpression(commandExpression, 'CustomRemoveCommand');

if (task.runNpmBuild) {
Expand All @@ -181,7 +181,7 @@ export class CdkBuildTaskPlugin implements IBuildTaskPlugin<ICdkBuildTaskConfig,
const p = await resolver.resolve(task.parameters);
const collapsed = await resolver.collapse(p);
const parametersAsString = CdkBuildTaskPlugin.GetParametersAsArgument(collapsed);
resolver.addResourceWithAttributes('CurrentTask', { Parameters : parametersAsString, AccountId : binding.target.accountId });
resolver.addResourceWithAttributes('CurrentTask', { Parameters: parametersAsString, AccountId: binding.target.accountId });
}

static GetEnvironmentVariables(target: IGenericTarget<ICdkTask>): Record<string, string> {
Expand All @@ -201,7 +201,7 @@ export class CdkBuildTaskPlugin implements IBuildTaskPlugin<ICdkBuildTaskConfig,
}

static GetParametersAsArgument(parameters: Record<string, any>): string {
if (!parameters) {return '';}
if (!parameters) { return ''; }
const entries = Object.entries(parameters);
return entries.reduce((prev, curr) => prev + ` -c '${curr[0]}=${curr[1]}'`, '');
}
Expand Down

0 comments on commit bafe5f8

Please sign in to comment.