Skip to content

Commit e454349

Browse files
authored
fix(apigateway-helper): fixed condition for cloudWatchRole creation (#468)
* updated condition for cloudWatchRole creation in gateway helper * added test for false cloudWatchRole in gateway helper * updated test method * updated test method
1 parent cd5c4f4 commit e454349

File tree

19 files changed

+45
-34
lines changed

19 files changed

+45
-34
lines changed

source/patterns/@aws-solutions-constructs/aws-apigateway-dynamodb/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ _Parameters_
7171
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the api.RestApi created by the construct.|
7272
|apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
7373
|dynamoTable|[`dynamodb.Table`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.Table.html)|Returns an instance of dynamodb.Table created by the construct.|
74-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
74+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
7575
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
7676

7777
## Default settings

source/patterns/@aws-solutions-constructs/aws-apigateway-dynamodb/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class ApiGatewayToDynamoDB extends Construct {
109109
public readonly dynamoTable: dynamodb.Table;
110110
public readonly apiGatewayRole: iam.Role;
111111
public readonly apiGateway: api.RestApi;
112-
public readonly apiGatewayCloudWatchRole: iam.Role;
112+
public readonly apiGatewayCloudWatchRole?: iam.Role;
113113
public readonly apiGatewayLogGroup: logs.LogGroup;
114114
/**
115115
* @summary Constructs a new instance of the ApiGatewayToDynamoDB class.

source/patterns/@aws-solutions-constructs/aws-apigateway-iot/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ _Parameters_
6969
|:-------------|:----------------|-----------------|
7070
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
7171
|apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
72-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
72+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
7373
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
7474

7575
## Default settings

source/patterns/@aws-solutions-constructs/aws-apigateway-iot/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface ApiGatewayToIotProps {
6161
*/
6262
export class ApiGatewayToIot extends Construct {
6363
public readonly apiGateway: api.RestApi;
64-
public readonly apiGatewayCloudWatchRole: iam.Role;
64+
public readonly apiGatewayCloudWatchRole?: iam.Role;
6565
public readonly apiGatewayLogGroup: logs.LogGroup;
6666
public readonly apiGatewayRole: iam.IRole;
6767
private readonly iotEndpoint: string;

source/patterns/@aws-solutions-constructs/aws-apigateway-kinesisstreams/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ _Parameters_
6363
|:-------------|:----------------|-----------------|
6464
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
6565
|apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
66-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
66+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
6767
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
6868
|kinesisStream|[`kinesis.Stream`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kinesis.Stream.html)|Returns an instance of the Kinesis stream created or used by the pattern.|
6969
|cloudwatchAlarms?|[`cloudwatch.Alarm[]`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudwatch.Alarm.html)|Returns an array of recommended CloudWatch Alarms created by the construct for Kinesis Data stream|

source/patterns/@aws-solutions-constructs/aws-apigateway-kinesisstreams/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface ApiGatewayToKinesisStreamsProps {
9696
export class ApiGatewayToKinesisStreams extends Construct {
9797
public readonly apiGateway: api.RestApi;
9898
public readonly apiGatewayRole: iam.Role;
99-
public readonly apiGatewayCloudWatchRole: iam.Role;
99+
public readonly apiGatewayCloudWatchRole?: iam.Role;
100100
public readonly apiGatewayLogGroup: logs.LogGroup;
101101
public readonly kinesisStream: kinesis.Stream;
102102
public readonly cloudwatchAlarms?: cloudwatch.Alarm[];

source/patterns/@aws-solutions-constructs/aws-apigateway-lambda/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ _Parameters_
6464
|:-------------|:----------------|-----------------|
6565
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
6666
|apiGateway|[`api.LambdaRestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.LambdaRestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
67-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
67+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
6868
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
6969

7070
## Default settings

source/patterns/@aws-solutions-constructs/aws-apigateway-lambda/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface ApiGatewayToLambdaProps {
5555
*/
5656
export class ApiGatewayToLambda extends Construct {
5757
public readonly apiGateway: api.RestApi;
58-
public readonly apiGatewayCloudWatchRole: iam.Role;
58+
public readonly apiGatewayCloudWatchRole?: iam.Role;
5959
public readonly apiGatewayLogGroup: logs.LogGroup;
6060
public readonly lambdaFunction: lambda.Function;
6161

source/patterns/@aws-solutions-constructs/aws-apigateway-lambda/test/test.apigateway-lambda.test.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,5 @@ test('Test deployment ApiGateway override cloudWatchRole = false', () => {
145145
}
146146
});
147147
// Assertion 1
148-
expect(stack).toHaveResourceLike("AWS::ApiGateway::Account", {
149-
CloudWatchRoleArn: {
150-
"Fn::GetAtt": [
151-
"apigatewaylambdaLambdaRestApiCloudWatchRoleA759E8AC",
152-
"Arn"
153-
]
154-
}
155-
});
148+
expect(stack).not.toHaveResource("AWS::ApiGateway::Account", {});
156149
});

source/patterns/@aws-solutions-constructs/aws-apigateway-sagemakerendpoint/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ _Parameters_
8383
|:-------------|:----------------|-----------------|
8484
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
8585
|apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
86-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
86+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
8787
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
8888

8989
## Sample API Usage

source/patterns/@aws-solutions-constructs/aws-apigateway-sagemakerendpoint/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface ApiGatewayToSageMakerEndpointProps {
7878
export class ApiGatewayToSageMakerEndpoint extends Construct {
7979
public readonly apiGateway: api.RestApi;
8080
public readonly apiGatewayRole: iam.Role;
81-
public readonly apiGatewayCloudWatchRole: iam.Role;
81+
public readonly apiGatewayCloudWatchRole?: iam.Role;
8282
public readonly apiGatewayLogGroup: logs.LogGroup;
8383

8484
/**

source/patterns/@aws-solutions-constructs/aws-apigateway-sqs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ _Parameters_
6565
|:-------------|:----------------|-----------------|
6666
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
6767
|apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
68-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
68+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
6969
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
7070
|sqsQueue|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)|Returns an instance of the SQS queue created by the pattern.|
7171
|deadLetterQueue?|[`sqs.DeadLetterQueue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.DeadLetterQueue.html)|Returns an instance of the DeadLetterQueue created by the pattern.|

source/patterns/@aws-solutions-constructs/aws-apigateway-sqs/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export interface ApiGatewayToSqsProps {
111111
export class ApiGatewayToSqs extends Construct {
112112
public readonly apiGateway: api.RestApi;
113113
public readonly apiGatewayRole: iam.Role;
114-
public readonly apiGatewayCloudWatchRole: iam.Role;
114+
public readonly apiGatewayCloudWatchRole?: iam.Role;
115115
public readonly apiGatewayLogGroup: logs.LogGroup;
116116
public readonly sqsQueue: sqs.Queue;
117117
public readonly deadLetterQueue?: sqs.DeadLetterQueue;

source/patterns/@aws-solutions-constructs/aws-cloudfront-apigateway-lambda/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _Parameters_
6666
|cloudFrontFunction?|[`cloudfront.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudfront.Function.html)|Returns an instance of the Cloudfront function created by the pattern.|
6767
|cloudFrontLoggingBucket|[`s3.Bucket`](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-readme.html)|Returns an instance of the logging bucket for CloudFront WebDistribution.|
6868
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
69-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
69+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
7070
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
7171
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
7272

source/patterns/@aws-solutions-constructs/aws-cloudfront-apigateway-lambda/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class CloudFrontToApiGatewayToLambda extends Construct {
7676
public readonly cloudFrontFunction?: cloudfront.Function;
7777
public readonly cloudFrontLoggingBucket?: s3.Bucket;
7878
public readonly apiGateway: api.RestApi;
79-
public readonly apiGatewayCloudWatchRole: iam.Role;
79+
public readonly apiGatewayCloudWatchRole?: iam.Role;
8080
public readonly apiGatewayLogGroup: logs.LogGroup;
8181
public readonly lambdaFunction: lambda.Function;
8282

source/patterns/@aws-solutions-constructs/aws-cognito-apigateway-lambda/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _Parameters_
9191
|userPool|[`cognito.UserPool`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.UserPool.html)|Returns an instance of cognito.UserPool created by the construct|
9292
|userPoolClient|[`cognito.UserPoolClient`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.UserPoolClient.html)|Returns an instance of cognito.UserPoolClient created by the construct|
9393
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.RestApi.html)|Returns an instance of api.RestApi created by the construct|
94-
|apiGatewayCloudWatchRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
94+
|apiGatewayCloudWatchRole?|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway for CloudWatch access.|
9595
|apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
9696
|apiGatewayAuthorizer|[`api.CfnAuthorizer`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.CfnAuthorizer.html)|Returns an instance of the api.CfnAuthorizer created by the construct for API Gateway methods authorization.|
9797
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of lambda.Function created by the construct|

source/patterns/@aws-solutions-constructs/aws-cognito-apigateway-lambda/lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class CognitoToApiGatewayToLambda extends Construct {
6666
public readonly userPool: cognito.UserPool;
6767
public readonly userPoolClient: cognito.UserPoolClient;
6868
public readonly apiGateway: api.RestApi;
69-
public readonly apiGatewayCloudWatchRole: iam.Role;
69+
public readonly apiGatewayCloudWatchRole?: iam.Role;
7070
public readonly apiGatewayLogGroup: logs.LogGroup;
7171
public readonly apiGatewayAuthorizer: api.CfnAuthorizer;
7272
public readonly lambdaFunction: lambda.Function;

0 commit comments

Comments
 (0)