-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ec2): flowlog setting add MaxAggregationInterval (#22098)
Added ability to specify MaxAggregationInterval from ec2.Flowlogs. The default value of 600 seconds usually works, so there is no effect on existing. The original CFn property is here. https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-flowlog.html#cfn-ec2-flowlog-maxaggregationinterval ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
8280709
commit dbede40
Showing
19 changed files
with
4,699 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/@aws-cdk/aws-ec2/test/integ.vpc-flow-logs-interval.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { PolicyStatement, Effect, ServicePrincipal } from '@aws-cdk/aws-iam'; | ||
import * as s3 from '@aws-cdk/aws-s3'; | ||
import { App, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core'; | ||
import { IntegTest } from '@aws-cdk/integ-tests'; | ||
import { FlowLog, FlowLogDestination, FlowLogResourceType, Vpc, FlowLogMaxAggregationInterval } from '../lib'; | ||
|
||
const app = new App(); | ||
|
||
|
||
class TestStack extends Stack { | ||
constructor(scope: App, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const vpc = new Vpc(this, 'VPC'); | ||
|
||
new FlowLog(this, 'FlowLogsCW', { | ||
resourceType: FlowLogResourceType.fromVpc(vpc), | ||
maxAggregationInterval: FlowLogMaxAggregationInterval.TEN_MINUTES, | ||
}); | ||
|
||
vpc.addFlowLog('FlowLogsS3', { | ||
destination: FlowLogDestination.toS3(), | ||
maxAggregationInterval: FlowLogMaxAggregationInterval.ONE_MINUTE, | ||
}); | ||
|
||
const bucket = new s3.Bucket(this, 'Bucket', { | ||
removalPolicy: RemovalPolicy.DESTROY, | ||
autoDeleteObjects: true, | ||
}); | ||
bucket.addToResourcePolicy(new PolicyStatement({ | ||
effect: Effect.ALLOW, | ||
principals: [new ServicePrincipal('delivery.logs.amazonaws.com')], | ||
actions: ['s3:PutObject'], | ||
resources: [bucket.arnForObjects(`AWSLogs/${this.account}/*`)], | ||
conditions: { | ||
StringEquals: { | ||
's3:x-amz-acl': 'bucket-owner-full-control', | ||
'aws:SourceAccount': this.account, | ||
}, | ||
ArnLike: { | ||
'aws:SourceArn': this.formatArn({ | ||
service: 'logs', | ||
resource: '*', | ||
}), | ||
}, | ||
}, | ||
})); | ||
bucket.addToResourcePolicy(new PolicyStatement({ | ||
effect: Effect.ALLOW, | ||
principals: [new ServicePrincipal('delivery.logs.amazonaws.com')], | ||
actions: ['s3:GetBucketAcl', 's3:ListBucket'], | ||
resources: [bucket.bucketArn], | ||
conditions: { | ||
StringEquals: { | ||
'aws:SourceAccount': this.account, | ||
}, | ||
ArnLike: { | ||
'aws:SourceArn': this.formatArn({ | ||
service: 'logs', | ||
resource: '*', | ||
}), | ||
}, | ||
}, | ||
})); | ||
|
||
vpc.addFlowLog('FlowLogsS3KeyPrefix', { | ||
destination: FlowLogDestination.toS3(bucket, 'prefix/'), | ||
}); | ||
} | ||
} | ||
|
||
|
||
new IntegTest(app, 'FlowLogs', { | ||
testCases: [ | ||
new TestStack(app, 'FlowLogsTestStack'), | ||
], | ||
}); | ||
|
||
app.synth(); |
19 changes: 19 additions & 0 deletions
19
...vpc-flow-logs-interval.integ.snapshot/FlowLogsDefaultTestDeployAssert6AFD1854.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "FlowLogsDefaultTestDeployAssert6AFD1854.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...c-flow-logs-interval.integ.snapshot/FlowLogsDefaultTestDeployAssert6AFD1854.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ws-cdk/aws-ec2/test/vpc-flow-logs-interval.integ.snapshot/FlowLogsFeatureFlag.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"69731f7ae982e377a617d06d1920c7fbeb360543d6b5f3da47406c123317a645": { | ||
"source": { | ||
"path": "FlowLogsFeatureFlag.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "69731f7ae982e377a617d06d1920c7fbeb360543d6b5f3da47406c123317a645.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
Oops, something went wrong.