Skip to content

Commit

Permalink
Merge branch 'main' into feat-validate-cloud-front-waf-region
Browse files Browse the repository at this point in the history
  • Loading branch information
gracelu0 authored Dec 2, 2024
2 parents 11a68bf + f091714 commit c94ec02
Show file tree
Hide file tree
Showing 21 changed files with 194 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ApplicationAssociator extends Construct {
this.associateCrossAccountStacks = targetBindResult.associateCrossAccountStacks;
cdk.Aspects.of(scope).add(new CheckedStageStackAssociator(this, {
associateCrossAccountStacks: this.associateCrossAccountStacks,
}));
}), { priority: cdk.AspectPriority.MUTATING });
}

/**
Expand All @@ -61,7 +61,7 @@ export class ApplicationAssociator extends Construct {
this.associatedStages.add(stage);
cdk.Aspects.of(stage).add(new CheckedStageStackAssociator(this, {
associateCrossAccountStacks: this.associateCrossAccountStacks,
}));
}), { priority: cdk.AspectPriority.MUTATING });
return stage;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Aspects, CfnOutput, CustomResource, Lazy, Token } from 'aws-cdk-lib';
import { AspectPriority, Aspects, CfnOutput, CustomResource, Lazy, Token } from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
import { ApiCallBase, IApiCall } from './api-call-base';
import { ExpectedResult } from './common';
Expand Down Expand Up @@ -51,7 +51,7 @@ export class HttpApiCall extends ApiCallBase {
}
}
},
});
}, { priority: AspectPriority.MUTATING });
}

public assertAtPath(_path: string, _expected: ExpectedResult): IApiCall {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArnFormat, CfnResource, CustomResource, Lazy, Stack, Aspects, CfnOutput } from 'aws-cdk-lib/core';
import { ArnFormat, CfnResource, CustomResource, Lazy, Stack, Aspects, CfnOutput, AspectPriority } from 'aws-cdk-lib/core';
import { Construct, IConstruct } from 'constructs';
import { ApiCallBase, IApiCall } from './api-call-base';
import { ExpectedResult } from './common';
Expand Down Expand Up @@ -125,7 +125,7 @@ export class AwsApiCall extends ApiCallBase {
}
}
},
});
}, { priority: AspectPriority.MUTATING });
}

public assertAtPath(path: string, expected: ExpectedResult): IApiCall {
Expand Down Expand Up @@ -281,6 +281,6 @@ export class LambdaInvokeFunction extends AwsApiCall {
})]);
}
},
});
}, { priority: AspectPriority.MUTATING });
}
}
1 change: 0 additions & 1 deletion packages/aws-cdk-lib/assertions/lib/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export class MatchResult {
*/
public toHumanStrings(): string[] {
const failures = new Array<MatchFailure>();
debugger;
recurse(this, []);

return failures.map(r => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as iam from '../../aws-iam';
import * as sns from '../../aws-sns';
import {
Annotations,
AspectPriority,
Aspects,
Aws,
CfnAutoScalingRollingUpdate, CfnCreationPolicy, CfnUpdatePolicy,
Expand Down Expand Up @@ -1573,7 +1574,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
this.spotPrice = props.spotPrice;

if (props.requireImdsv2) {
Aspects.of(this).add(new AutoScalingGroupRequireImdsv2Aspect());
Aspects.of(this).add(new AutoScalingGroupRequireImdsv2Aspect(), { priority: AspectPriority.MUTATING });
}

this.node.addValidation({ validate: () => this.validateTargetGroup() });
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-backup/lib/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BackupableResourcesCollector } from './backupable-resources-collector';
import { IBackupPlan } from './plan';
import { BackupResource, TagOperation } from './resource';
import * as iam from '../../aws-iam';
import { Lazy, Resource, Aspects } from '../../core';
import { Lazy, Resource, Aspects, AspectPriority } from '../../core';

/**
* Options for a BackupSelection
Expand Down Expand Up @@ -140,7 +140,7 @@ export class BackupSelection extends Resource implements iam.IGrantable {
}

if (resource.construct) {
Aspects.of(resource.construct).add(this.backupableResourcesCollector);
Aspects.of(resource.construct).add(this.backupableResourcesCollector, { priority: AspectPriority.MUTATING });
// Cannot push `this.backupableResourcesCollector.resources` to
// `this.resources` here because it has not been evaluated yet.
// Will be concatenated to `this.resources` in a `Lazy.list`
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-ec2/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UserData } from './user-data';
import { BlockDevice } from './volume';
import { IVpc, Subnet, SubnetSelection } from './vpc';
import * as iam from '../../aws-iam';
import { Annotations, Aspects, Duration, FeatureFlags, Fn, IResource, Lazy, Resource, Stack, Tags, Token } from '../../core';
import { Annotations, AspectPriority, Aspects, Duration, FeatureFlags, Fn, IResource, Lazy, Resource, Stack, Tags, Token } from '../../core';
import { md5hash } from '../../core/lib/helpers-internal';
import * as cxapi from '../../cx-api';

Expand Down Expand Up @@ -669,7 +669,7 @@ export class Instance extends Resource implements IInstance {
}));

if (props.requireImdsv2) {
Aspects.of(this).add(new InstanceRequireImdsv2Aspect());
Aspects.of(this).add(new InstanceRequireImdsv2Aspect(), { priority: AspectPriority.MUTATING });
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IKey } from '../../aws-kms';
import * as logs from '../../aws-logs';
import * as s3 from '../../aws-s3';
import * as cloudmap from '../../aws-servicediscovery';
import { Aws, Duration, IResource, Resource, Stack, Aspects, ArnFormat, IAspect, Token, Names } from '../../core';
import { Aws, Duration, IResource, Resource, Stack, Aspects, ArnFormat, IAspect, Token, Names, AspectPriority } from '../../core';

const CLUSTER_SYMBOL = Symbol.for('@aws-cdk/aws-ecs/lib/cluster.Cluster');

Expand Down Expand Up @@ -282,7 +282,7 @@ export class Cluster extends Resource implements ICluster {
// since it's harmless, but we'd prefer not to add unexpected new
// resources to the stack which could surprise users working with
// brown-field CDK apps and stacks.
Aspects.of(this).add(new MaybeCreateCapacityProviderAssociations(this, id));
Aspects.of(this).add(new MaybeCreateCapacityProviderAssociations(this, id), { priority: AspectPriority.MUTATING });
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-iam/lib/permissions-boundary.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IConstruct } from 'constructs';
import { CfnRole, CfnUser } from './iam.generated';
import { IManagedPolicy } from './managed-policy';
import { Aspects, CfnResource } from '../../core';
import { AspectPriority, Aspects, CfnResource } from '../../core';

/**
* Modify the Permissions Boundaries of Users and Roles in a construct tree
Expand Down Expand Up @@ -40,7 +40,7 @@ export class PermissionsBoundary {
node.addPropertyOverride('PermissionsBoundary', boundaryPolicy.managedPolicyArn);
}
},
});
}, { priority: AspectPriority.MUTATING });
}

/**
Expand All @@ -56,6 +56,6 @@ export class PermissionsBoundary {
node.addPropertyDeletionOverride('PermissionsBoundary');
}
},
});
}, { priority: AspectPriority.MUTATING });
}
}
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-iam/lib/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ImportedRole } from './private/imported-role';
import { MutatingPolicyDocumentAdapter } from './private/policydoc-adapter';
import { PrecreatedRole } from './private/precreated-role';
import { AttachedPolicies, UniqueStringSet } from './private/util';
import { ArnFormat, Duration, Resource, Stack, Token, TokenComparison, Aspects, Annotations, RemovalPolicy } from '../../core';
import { ArnFormat, Duration, Resource, Stack, Token, TokenComparison, Aspects, Annotations, RemovalPolicy, AspectPriority } from '../../core';
import { getCustomizeRolesConfig, getPrecreatedRoleConfig, CUSTOMIZE_ROLES_CONTEXT_KEY, CustomizeRoleConfig } from '../../core/lib/helpers-internal';

const MAX_INLINE_SIZE = 10000;
Expand Down Expand Up @@ -493,7 +493,7 @@ export class Role extends Resource implements IRole {
this.splitLargePolicy();
}
},
});
}, { priority: AspectPriority.MUTATING });
}

this.policyFragment = new ArnPrincipal(this.roleArn).policyFragment;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-servicecatalog/lib/portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export class Portfolio extends PortfolioBase {
(c as Portfolio).addBucketPermissionsToSharedAccounts();
};
},
});
}, { priority: cdk.AspectPriority.MUTATING });
}

protected generateUniqueHash(value: string): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Resources": {
"ASG": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"MinSize": "1",
"MaxSize": "5"
},
"CreationPolicy": {
"NonExistentResourceAttribute": "Bucket1"
},
"UpdatePolicy": {
"NonExistentResourceAttribute": "Bucket1"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ describe('CDK Include', () => {
);
});

test('preserves unknown policy attributes', () => {
const cfnTemplate = includeTestTemplate(stack, 'non-existent-policy-attribute.json');
Template.fromStack(stack).templateMatches(
loadTestFileToJsObject('non-existent-policy-attribute.json'),
);
});

test("correctly handles referencing the ingested template's resources across Stacks", () => {
// for cross-stack sharing to work, we need an App
const app = new core.App();
Expand Down
Loading

0 comments on commit c94ec02

Please sign in to comment.