Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ class IpamScope extends Resource implements IIpamScopeBase {

constructor(scope: Construct, id: string, props: IpamScopeProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
this._ipamScope = new CfnIPAMScope(scope, 'IpamScope', {
ipamId: props.ipamId,
});
Expand Down Expand Up @@ -511,6 +513,8 @@ export class Ipam extends Resource {

constructor(scope: Construct, id: string, props?: IpamProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
if (props?.ipamName) {
Tags.of(this).add(NAME_TAG, props.ipamName);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/lib/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ export class InternetGateway extends Resource implements IRouteTarget {

constructor(scope: Construct, id: string, props: InternetGatewayProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.routerType = RouterType.GATEWAY;

Expand Down Expand Up @@ -340,6 +342,8 @@ export class VPNGatewayV2 extends Resource implements IRouteTarget {
super(scope, id, {
physicalName: props.vpnGatewayName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.routerType = RouterType.GATEWAY;

Expand Down Expand Up @@ -424,6 +428,8 @@ export class NatGateway extends Resource implements IRouteTarget {

constructor(scope: Construct, id: string, props: NatGatewayProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.routerType = RouterType.NAT_GATEWAY;

Expand Down Expand Up @@ -490,6 +496,8 @@ export class VPCPeeringConnection extends Resource implements IRouteTarget {

constructor(scope: Construct, id: string, props: VPCPeeringConnectionProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.routerType = RouterType.VPC_PEERING_CONNECTION;

Expand Down Expand Up @@ -717,6 +725,8 @@ export class Route extends Resource implements IRouteV2 {

constructor(scope: Construct, id: string, props: RouteProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.target = props.target;
this.routeTable = props.routeTable;
Expand Down Expand Up @@ -789,6 +799,8 @@ export class RouteTable extends Resource implements IRouteTable {

constructor(scope: Construct, id: string, props: RouteTableProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.resource = new CfnRouteTable(this, 'RouteTable', {
vpcId: props.vpc.vpcId,
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ class VPCCidrBlock extends Resource implements IVPCCidrBlock {

constructor(scope: Construct, id: string, props: VPCCidrBlockProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
this.resource = new CfnVPCCidrBlock(this, id, props);
this.node.defaultChild = this.resource;
this.cidrBlock = props.cidrBlock;
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/pyspark-etl-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType } from '../constants';
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import { Code } from '../code';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Python Spark ETL job
Expand Down Expand Up @@ -84,6 +85,8 @@ export class PySparkEtlJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType, Execution
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import * as cdk from 'aws-cdk-lib/core';
import { Code } from '../code';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for PySparkFlexEtlJob
Expand Down Expand Up @@ -82,6 +83,8 @@ export class PySparkFlexEtlJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType } from '../constants';
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import { Code } from '../code';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Python Spark ETL job
Expand Down Expand Up @@ -84,6 +85,8 @@ export class PySparkStreamingJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/python-shell-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import { Job, JobProperties } from './job';
import { Construct } from 'constructs';
import { JobType, GlueVersion, PythonVersion, MaxCapacity, JobLanguage } from '../constants';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Python Shell job
Expand Down Expand Up @@ -53,6 +54,8 @@ export class PythonShellJob extends Job {
*/
constructor(scope: Construct, id: string, props: PythonShellJobProps) {
super(scope, id, { physicalName: props.jobName });
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/ray-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import { Job, JobProperties } from './job';
import { Construct } from 'constructs';
import { JobType, GlueVersion, WorkerType, Runtime } from '../constants';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Ray Glue job
Expand Down Expand Up @@ -49,6 +50,8 @@ export class RayJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.jobName = props.jobName ?? '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, WorkerType } from '../constants';
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import { Code } from '../code';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Scala Spark ETL job
Expand Down Expand Up @@ -81,6 +82,8 @@ export class ScalaSparkEtlJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { JobType, GlueVersion, JobLanguage, WorkerType, ExecutionClass } from '.
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import * as cdk from 'aws-cdk-lib/core';
import { Code } from '../code';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Flex Jobs class
Expand Down Expand Up @@ -109,6 +110,8 @@ export class ScalaSparkFlexEtlJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Job, JobProperties } from './job';
import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, WorkerType } from '../constants';
import { SparkUIProps, SparkUILoggingLocation, validateSparkUiPrefix, cleanSparkUiPrefixForGrant } from './spark-ui-utils';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* Properties for creating a Scala Spark ETL job
Expand Down Expand Up @@ -80,6 +81,8 @@ export class ScalaSparkStreamingJob extends Job {
super(scope, id, {
physicalName: props.jobName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

// Set up role and permissions for principal
this.role = props.role, {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/triggers/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
NotifyEventTriggerOptions,
ConditionalTriggerOptions,
} from './trigger-options';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';

/**
* The base interface for Glue Workflow
Expand Down Expand Up @@ -407,6 +408,8 @@ export class Workflow extends WorkflowBase {
super(scope, id, {
physicalName: props?.workflowName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

const resource = new CfnWorkflow(this, 'Resource', {
name: this.physicalName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ export class Application extends ApplicationBase {

constructor(scope: Construct, id: string, props: ApplicationProps) {
super(scope, id, { physicalName: props.applicationName });
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
validateApplicationProps(props);

this.role = props.role ?? new iam.Role(this, 'Role', {
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/lib/parameter-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export class ParameterGroup extends Resource implements IParameterGroup {

constructor(scope: Construct, id: string, props: ParameterGroupProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

const resource = new CfnDBParameterGroup(this, 'Resource', {
name: props.parameterGroupName,
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-pipes-alpha/lib/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class Pipe extends PipeBase {
constructor(scope: Construct, id: string, props: PipeProps) {

super(scope, id, { physicalName: props.pipeName });
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

/**
* Role setup
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/lib/api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export class RateLimitedApiKey extends ApiKeyBase {
super(scope, id, {
physicalName: props.apiKeyName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

const resource = new ApiKey(this, 'Resource', props);

Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/lib/authorizers/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ export class RequestAuthorizer extends LambdaAuthorizer {

constructor(scope: Construct, id: string, props: RequestAuthorizerProps) {
super(scope, id, props);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

if ((props.resultsCacheTtl === undefined || props.resultsCacheTtl.toSeconds() !== 0) && props.identitySources.length === 0) {
throw new Error('At least one Identity Source is required for a REQUEST-based Lambda authorizer if caching is enabled.');
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ export class ProxyResource extends Resource {
defaultIntegration: props.defaultIntegration,
defaultMethodOptions: props.defaultMethodOptions,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

const anyMethod = props.anyMethod ?? true;
if (anyMethod) {
Expand Down
4 changes: 4 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,8 @@ export class RestApi extends RestApiBase {

constructor(scope: Construct, id: string, props: RestApiProps = { }) {
super(scope, id, props);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

if (props.minCompressionSize !== undefined && props.minimumCompressionSize !== undefined) {
throw new Error('both properties minCompressionSize and minimumCompressionSize cannot be set at once.');
Expand Down Expand Up @@ -985,6 +987,8 @@ class RootResource extends ResourceBase {

constructor(api: RestApiBase, props: ResourceOptions, resourceId: string) {
super(api, 'Default');
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, resourceId);

this.parentResource = undefined;
this.defaultIntegration = props.defaultIntegration;
Expand Down
66 changes: 66 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { testDeprecated } from '@aws-cdk/cdk-build-tools';
import { cx_api } from '../..';
import { Template } from '../../assertions';
import { UserPool } from '../../aws-cognito';
import { GatewayVpcEndpoint } from '../../aws-ec2';
import { App, CfnElement, CfnResource, Lazy, RemovalPolicy, Size, Stack } from '../../core';
import { JSII_RUNTIME_SYMBOL } from '../../core/lib/constants';
import * as apigw from '../lib';

describe('restapi', () => {
Expand Down Expand Up @@ -1475,3 +1478,66 @@ describe('SpecRestApi', () => {
});
});
});

describe('telemetry metadata', () => {
it('redaction happens when feature flag is enabled', () => {
const app = new App();
app.node.setContext(cx_api.ENABLE_ADDITIONAL_METADATA_COLLECTION, true);
const stack = new Stack(app);

const mockConstructor = {
[JSII_RUNTIME_SYMBOL]: {
fqn: 'aws-cdk-lib.aws-apigateway.RestApi',
},
};
jest.spyOn(Object, 'getPrototypeOf').mockReturnValue({
constructor: mockConstructor,
});

const api = new apigw.RestApi(stack, 'myapi', {
defaultMethodOptions: {
apiKeyRequired: true,
authorizer: new apigw.CognitoUserPoolsAuthorizer(stack, 'myauthorizer', {
cognitoUserPools: [new UserPool(stack, 'myuserpool')],
}),
},
});

expect(api.node.metadata).toStrictEqual([{
data: {
defaultMethodOptions: {
apiKeyRequired: '*',
authorizer: '*',
},
},
trace: undefined,
type: 'aws:cdk:analytics:construct',
}]);
});

it('redaction happens when feature flag is disabled', () => {
const app = new App();
app.node.setContext(cx_api.ENABLE_ADDITIONAL_METADATA_COLLECTION, false);
const stack = new Stack(app);

const mockConstructor = {
[JSII_RUNTIME_SYMBOL]: {
fqn: 'aws-cdk-lib.aws-apigateway.RestApi',
},
};
jest.spyOn(Object, 'getPrototypeOf').mockReturnValue({
constructor: mockConstructor,
});

const api = new apigw.RestApi(stack, 'myapi', {
defaultMethodOptions: {
apiKeyRequired: true,
authorizer: new apigw.CognitoUserPoolsAuthorizer(stack, 'myauthorizer', {
cognitoUserPools: [new UserPool(stack, 'myuserpool')],
}),
},
});

expect(api.node.metadata).toStrictEqual([]);
});
});
Loading
Loading