Skip to content

Commit cdb275f

Browse files
authored
Merge branch 'master' into robertd/fix-core-runtime-selection
2 parents eb4d863 + a67d85f commit cdb275f

File tree

23 files changed

+457
-23
lines changed

23 files changed

+457
-23
lines changed

packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"Arn"
7373
]
7474
},
75-
"Runtime": "nodejs12.x"
75+
"Runtime": "nodejs12.x",
76+
"Description": "veni vidi vici"
7677
},
7778
"DependsOn": [
7879
"CustomReflectCustomResourceProviderRoleB4B29AEC"

packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TestStack extends Stack {
2424
const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
2525
codeDirectory: `${__dirname}/core-custom-resource-provider-fixture`,
2626
runtime: CustomResourceProviderRuntime.NODEJS_12,
27+
description: 'veni vidi vici',
2728
});
2829

2930
const cr = new CustomResource(this, 'MyResource', {

packages/@aws-cdk/aws-cloudwatch/lib/private/rendering.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function metricGraphJson(metric: IMetric, yAxis?: string, id?: string) {
5555

5656
withExpression(expr) {
5757
options.expression = expr.expression;
58+
if (expr.period && expr.period !== 300) { options.period = expr.period; }
5859
},
5960
});
6061

packages/@aws-cdk/aws-cloudwatch/test/integ.math-alarm-and-dashboard.expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
{
8989
"Ref": "AWS::Region"
9090
},
91-
"\",\"metrics\":[[{\"label\":\"Total Messages\",\"expression\":\"m1+m2\"}],[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
91+
"\",\"metrics\":[[{\"label\":\"Total Messages\",\"expression\":\"m1+m2\",\"period\":60}],[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
9292
{
9393
"Fn::GetAtt": [
9494
"queue",
@@ -120,7 +120,7 @@
120120
{
121121
"Ref": "AWS::Region"
122122
},
123-
"\",\"metrics\":[[{\"label\":\"Total Messages\",\"expression\":\"m1+m2\"}],[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
123+
"\",\"metrics\":[[{\"label\":\"Total Messages\",\"expression\":\"m1+m2\",\"period\":60}],[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
124124
{
125125
"Fn::GetAtt": [
126126
"queue",

packages/@aws-cdk/aws-cloudwatch/test/test.metric-math.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ export = {
219219
test.done();
220220
},
221221

222+
'top level period in a MathExpression is respected in its metrics'(test: Test) {
223+
const graph = new GraphWidget({
224+
left: [
225+
a,
226+
new MathExpression({
227+
expression: 'a + b',
228+
usingMetrics: { a, b },
229+
period: Duration.minutes(1),
230+
}),
231+
],
232+
});
233+
234+
// THEN
235+
graphMetricsAre(test, graph, [
236+
['Test', 'ACount'],
237+
[{ label: 'a + b', expression: 'a + b', period: 60 }],
238+
['Test', 'ACount', { visible: false, id: 'a', period: 60 }],
239+
['Test', 'BCount', { visible: false, id: 'b', period: 60 }],
240+
]);
241+
test.done();
242+
},
243+
222244
'MathExpression controls period of metrics transitively used in it'(test: Test) {
223245
// Same as the previous test, but recursively
224246

packages/@aws-cdk/aws-elasticloadbalancingv2/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ lb.addRedirect({
182182

183183
If you do not provide any options for this method, it redirects HTTP port 80 to HTTPS port 443.
184184

185+
By default all ingress traffic will be allowed on the source port. If you want to be more selective with your
186+
ingress rules then set `open: false` and use the listener's `connections` object to selectively grant access to the listener.
187+
185188
## Defining a Network Load Balancer
186189

187190
Network Load Balancers are defined in a similar way to Application Load

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
119119
return this.addListener(`Redirect${sourcePort}To${targetPort}`, {
120120
protocol: props.sourceProtocol ?? ApplicationProtocol.HTTP,
121121
port: sourcePort,
122-
open: true,
122+
open: props.open ?? true,
123123
defaultAction: ListenerAction.redirect({
124124
port: targetPort,
125125
protocol: props.targetProtocol ?? ApplicationProtocol.HTTPS,
@@ -665,4 +665,19 @@ export interface ApplicationLoadBalancerRedirectConfig {
665665
*/
666666
readonly targetPort?: number;
667667

668+
/**
669+
* Allow anyone to connect to this listener
670+
*
671+
* If this is specified, the listener will be opened up to anyone who can reach it.
672+
* For internal load balancers this is anyone in the same VPC. For public load
673+
* balancers, this is anyone on the internet.
674+
*
675+
* If you want to be more selective about who can access this load
676+
* balancer, set this to `false` and use the listener's `connections`
677+
* object to selectively grant access to the listener.
678+
*
679+
* @default true
680+
*/
681+
readonly open?: boolean;
682+
668683
}

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ export class ApplicationTargetGroup extends TargetGroupBase implements IApplicat
123123

124124
if (props) {
125125
if (props.slowStart !== undefined) {
126+
if (props.slowStart.toSeconds() < 30 || props.slowStart.toSeconds() > 900) {
127+
throw new Error('Slow start duration value must be between 30 and 900 seconds.');
128+
}
126129
this.setAttribute('slow_start.duration_seconds', props.slowStart.toSeconds().toString());
127130
}
128131
if (props.stickinessCookieDuration) {

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,31 @@ describe('tests', () => {
727727
});
728728
});
729729

730+
test('Can supress default ingress rules on a simple redirect response', () => {
731+
// GIVEN
732+
const stack = new cdk.Stack();
733+
const vpc = new ec2.Vpc(stack, 'Stack');
734+
735+
const loadBalancer = new elbv2.ApplicationLoadBalancer(stack, 'LB', {
736+
vpc,
737+
});
738+
739+
// WHEN
740+
loadBalancer.addRedirect({ open: false });
741+
742+
// THEN
743+
expect(stack).not.toHaveResourceLike('AWS::EC2::SecurityGroup', {
744+
SecurityGroupIngress: [
745+
{
746+
CidrIp: '0.0.0.0/0',
747+
Description: 'Allow from anyone on port 80',
748+
IpProtocol: 'tcp',
749+
},
750+
],
751+
});
752+
753+
});
754+
730755
test('Can add simple redirect responses with custom values', () => {
731756
// GIVEN
732757
const stack = new cdk.Stack();

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/target-group.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,21 @@ describe('tests', () => {
205205
});
206206
}).toThrow(/Stickiness cookie duration value must be between 1 second and 7 days \(604800 seconds\)./);
207207
});
208+
209+
test('Bad slow start duration value', () => {
210+
// GIVEN
211+
const app = new cdk.App();
212+
const stack = new cdk.Stack(app, 'Stack');
213+
const vpc = new ec2.Vpc(stack, 'VPC', {});
214+
215+
// THEN
216+
[cdk.Duration.minutes(16), cdk.Duration.seconds(29)].forEach((badDuration, i) => {
217+
expect(() => {
218+
new elbv2.ApplicationTargetGroup(stack, `TargetGroup${i}`, {
219+
slowStart: badDuration,
220+
vpc,
221+
});
222+
}).toThrow(/Slow start duration value must be between 30 and 900 seconds./);
223+
});
224+
});
208225
});

0 commit comments

Comments
 (0)