forked from widdix/aws-cf-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed fixed names from flow logs template and added test
- Loading branch information
1 parent
9b60c0e
commit 2d20739
Showing
10 changed files
with
143 additions
and
72 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
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
39 changes: 39 additions & 0 deletions
39
test/src/test/java/de/widdix/awscftemplates/vpc/TestVPCFlowLogs.java
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,39 @@ | ||
package de.widdix.awscftemplates.vpc; | ||
|
||
import com.amazonaws.services.cloudformation.model.Parameter; | ||
import de.widdix.awscftemplates.ACloudFormationTest; | ||
import org.junit.Test; | ||
|
||
public class TestVPCFlowLogs extends ACloudFormationTest { | ||
|
||
@Test | ||
public void test() { | ||
final String vpcStackName = "vpc-2azs-" + this.random8String(); | ||
final String flowLogsStackName = "vpc-flow-logs-" + this.random8String(); | ||
final String classB = "10"; | ||
final String keyName = "key-" + this.random8String(); | ||
try { | ||
this.createKey(keyName); | ||
try { | ||
this.createStack(vpcStackName, | ||
"vpc/vpc-2azs.yaml", | ||
new Parameter().withParameterKey("ClassB").withParameterValue(classB) | ||
); | ||
try { | ||
this.createStack(flowLogsStackName, | ||
"vpc/vpc-flow-logs.yaml", | ||
new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) | ||
); | ||
// TODO how can we check if this stack works? | ||
} finally { | ||
this.deleteStack(flowLogsStackName); | ||
} | ||
} finally { | ||
this.deleteStack(vpcStackName); | ||
} | ||
} finally { | ||
this.deleteKey(keyName); | ||
} | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: 'VPC: Publish flow logs to CloudWatch Logs, a cloudonaut.io template, contributed by https://github.com/statik' | ||
Metadata: | ||
'AWS::CloudFormation::Interface': | ||
ParameterGroups: | ||
- Label: | ||
default: 'Parent Stacks' | ||
Parameters: | ||
- ParentVPCStack | ||
- Label: | ||
default: 'Flow Logs Parameters' | ||
Parameters: | ||
- RetentionInDays | ||
- TrafficType | ||
Parameters: | ||
ParentVPCStack: | ||
Description: 'Stack name of parent VPC stack based on vpc/vpc-*azs.yaml template.' | ||
Type: String | ||
RetentionInDays: | ||
Description: 'Specifies the number of days you want to retain log events.' | ||
Type: Number | ||
Default: 14 | ||
AllowedValues: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653] | ||
TrafficType: | ||
Description: 'The type of traffic to log.' | ||
Type: String | ||
Default: REJECT | ||
AllowedValues: | ||
- ACCEPT | ||
- REJECT | ||
- ALL | ||
Resources: | ||
Role: | ||
Type: 'AWS::IAM::Role' | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- 'vpc-flow-logs.amazonaws.com' | ||
Action: 'sts:AssumeRole' | ||
Policies: | ||
- PolicyName: 'flowlogs-policy' | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Action: | ||
- 'logs:CreateLogGroup' | ||
- 'logs:CreateLogStream' | ||
- 'logs:PutLogEvents' | ||
- 'logs:DescribeLogGroups' | ||
- 'logs:DescribeLogStreams' | ||
Resource: '*' | ||
LogGroup: | ||
Type: 'AWS::Logs::LogGroup' | ||
Properties: | ||
RetentionInDays: !Ref RetentionInDays | ||
FlowLog: | ||
Type: 'AWS::EC2::FlowLog' | ||
Properties: | ||
DeliverLogsPermissionArn: !GetAtt 'Role.Arn' | ||
LogGroupName: !Ref LogGroup | ||
ResourceId : | ||
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC' | ||
ResourceType: 'VPC' | ||
TrafficType: !Ref TrafficType | ||
Outputs: | ||
TemplateID: | ||
Description: 'cloudonaut.io template id.' | ||
Value: 'vpc/vpc-flowlog' | ||
LogGroupName: | ||
Description: 'The name of the CloudWatch Logs log group where Amazon EC2 publishes your flow logs.' | ||
Value: !Ref LogGroup | ||
LogGroupARN: | ||
Description: 'The ARN of the CloudWatch Logs log group where Amazon EC2 publishes your flow logs.' | ||
Value: !GetAtt 'LogGroup.Arn' |
This file was deleted.
Oops, something went wrong.