Skip to content

Commit

Permalink
added cfn-lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig committed Jul 23, 2018
1 parent 2429f28 commit af42548
Show file tree
Hide file tree
Showing 29 changed files with 470 additions and 694 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**(Override all values in parentheses)**

(Run `yamllint folder/template.yaml` and `aws cloudformation validate-template --template-body file://folder/template.yaml` before you open a PR)
(Run `yamllint folder/template.yaml`, `cfn-lint -i E1019 E3002 E2520 -t folder/template.yaml`, and `aws cloudformation validate-template --template-body file://folder/template.yaml` before you open a PR)

(Do not include multiple changes in one PR. Open additional PRs instead.)

Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ python:
install:
- 'pip install yamllint'
- 'pip install awscli'
- 'pip install cfn-lint'
script:
- 'yamllint .'
- 'find . -type f -name ''*.yaml'' | while read file; do set -ex && cfn-lint -i E1019 E3002 E2520 -t "$file"; done;' # TODO get rid of check ignores
- 'find . -type f -name ''*.yaml'' | while read file; do set -ex && grep -q "LICENSE-2.0" "$file"; done;'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then find . -type f -name ''*.yaml'' | while read file; do set -ex && aws s3 cp "$file" "s3://travis-aws-cf-templates/$TRAVIS_COMMIT/$file" && aws cloudformation validate-template --template-url "https://s3.amazonaws.com/travis-aws-cf-templates/$TRAVIS_COMMIT/$file" > /dev/null; done; fi'
17 changes: 6 additions & 11 deletions ec2/ec2-auto-recovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,11 @@ Resources:
Condition: HasZone
Type: 'AWS::Route53::RecordSet'
Properties:
HostedZoneId:
'Fn::ImportValue': !Sub '${ParentZoneStack}-HostedZoneId'
HostedZoneId: {'Fn::ImportValue': !Sub '${ParentZoneStack}-HostedZoneId'}
Name: !Sub
- '${SubDomainNameWithDot}${HostedZoneName}'
- SubDomainNameWithDot: !Ref SubDomainNameWithDot
HostedZoneName:
'Fn::ImportValue': !Sub '${ParentZoneStack}-HostedZoneName'
HostedZoneName: {'Fn::ImportValue': !Sub '${ParentZoneStack}-HostedZoneName'}
ResourceRecords:
- !Ref ElasticIP
TTL: '60'
Expand All @@ -187,8 +185,7 @@ Resources:
Properties:
GroupSet:
- !Ref SecurityGroup
SubnetId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-${SubnetName}'
SubnetId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-${SubnetName}'}
EIPAssociation:
Type: 'AWS::EC2::EIPAssociation'
Properties:
Expand All @@ -202,8 +199,7 @@ Resources:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: !Ref Name
VpcId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
SecurityGroupInSSHBastion:
Type: 'AWS::EC2::SecurityGroupIngress'
Condition: HasSSHBastionSecurityGroup
Expand All @@ -212,8 +208,7 @@ Resources:
IpProtocol: tcp
FromPort: 22
ToPort: 22
SourceSecurityGroupId:
'Fn::ImportValue': !Sub '${ParentSSHBastionStack}-SecurityGroup'
SourceSecurityGroupId: {'Fn::ImportValue': !Sub '${ParentSSHBastionStack}-SecurityGroup'}
SecurityGroupInSSHWorld:
Type: 'AWS::EC2::SecurityGroupIngress'
Condition: HasNotSSHBastionSecurityGroup
Expand Down Expand Up @@ -572,7 +567,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 80
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: InstanceId
Value: !Ref VirtualMachine
Expand Down
79 changes: 31 additions & 48 deletions ecs/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ Resources:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: 'ecs-cluster-alb'
VpcId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
ALBSecurityGroupInHttpWorld:
Type: 'AWS::EC2::SecurityGroupIngress'
Condition: HasNotAuthProxySecurityGroup
Expand All @@ -350,8 +349,7 @@ Resources:
IpProtocol: tcp
FromPort: 80
ToPort: 80
SourceSecurityGroupId:
'Fn::ImportValue': !Sub '${ParentAuthProxyStack}-SecurityGroup'
SourceSecurityGroupId: {'Fn::ImportValue': !Sub '${ParentAuthProxyStack}-SecurityGroup'}
ALBSecurityGroupInHttpsAuthProxy:
Type: 'AWS::EC2::SecurityGroupIngress'
Condition: HasAuthProxySecurityGroupAndLoadBalancerCertificateArn
Expand All @@ -360,14 +358,12 @@ Resources:
IpProtocol: tcp
FromPort: 443
ToPort: 443
SourceSecurityGroupId:
'Fn::ImportValue': !Sub '${ParentAuthProxyStack}-SecurityGroup'
SourceSecurityGroupId: {'Fn::ImportValue': !Sub '${ParentAuthProxyStack}-SecurityGroup'}
SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: 'ecs-cluster'
VpcId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
SecurityGroupIngress:
- SourceSecurityGroupId: !Ref ALBSecurityGroup
FromPort: 0
Expand All @@ -381,8 +377,7 @@ Resources:
IpProtocol: tcp
FromPort: 22
ToPort: 22
SourceSecurityGroupId:
'Fn::ImportValue': !Sub '${ParentSSHBastionStack}-SecurityGroup'
SourceSecurityGroupId: {'Fn::ImportValue': !Sub '${ParentSSHBastionStack}-SecurityGroup'}
SecurityGroupInSSHWorld:
Type: 'AWS::EC2::SecurityGroupIngress'
Condition: HasNotSSHBastionSecurityGroup
Expand All @@ -405,7 +400,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: LoadBalancer
Value: !GetAtt 'LoadBalancer.LoadBalancerFullName'
Expand All @@ -424,7 +419,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: LoadBalancer
Value: !GetAtt 'LoadBalancer.LoadBalancerFullName'
Expand All @@ -443,7 +438,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: LoadBalancer
Value: !GetAtt 'LoadBalancer.LoadBalancerFullName'
Expand All @@ -462,7 +457,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: LoadBalancer
Value: !GetAtt 'LoadBalancer.LoadBalancerFullName'
Expand All @@ -476,19 +471,13 @@ Resources:
- !Ref ALBSecurityGroup
Subnets: !If
- HasLoadBalancerSchemeInternal
- !Split
- ','
- 'Fn::ImportValue':
!Sub '${ParentVPCStack}-SubnetsPrivate'
- !Split
- ','
- 'Fn::ImportValue':
!Sub '${ParentVPCStack}-SubnetsPublic'
- !Split [',', {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetsPrivate'}]
- !Split [',', {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetsPublic'}]
DefaultTargetGroup: # this is used as the fall-back target group and is used to health checking the ECS agent. Services use their own ListenerRules to accept traffic based on path prefixes.
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
HealthCheckIntervalSeconds: 15
HealthCheckPort: 51678
HealthCheckPort: '51678'
HealthCheckPath: '/'
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 10
Expand All @@ -498,11 +487,10 @@ Resources:
HttpCode: '200-299'
Port: 80 # port 80 is a reserved port that is never used by the agent, so we are safe to use it here
Protocol: HTTP
VpcId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
TargetGroupAttributes:
- Key: 'deregistration_delay.timeout_seconds'
Value: 0
Value: '0'
HttpListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
Expand Down Expand Up @@ -919,13 +907,9 @@ Resources:
- - NotificationTypes:
- 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR'
- 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR'
TopicARN:
'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- !Ref 'AWS::NoValue'
VPCZoneIdentifier: !Split
- ','
- 'Fn::ImportValue':
!Sub '${ParentVPCStack}-Subnets${SubnetsReach}'
TopicARN: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
- []
VPCZoneIdentifier: !Split [',', {'Fn::ImportValue': !Sub '${ParentVPCStack}-Subnets${SubnetsReach}'}]
Tags:
- Key: Name
Value: 'ecs-cluster'
Expand Down Expand Up @@ -956,7 +940,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 80
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: AutoScalingGroupName
Value: !Ref AutoScalingGroup
Expand All @@ -981,7 +965,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 600
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: QueueName
Value: !GetAtt 'AutoScalingGroupLifecycleHookQueue.QueueName'
Expand All @@ -1002,7 +986,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: QueueName
Value: !GetAtt 'AutoScalingGroupLifecycleHookDeadLetterQueue.QueueName'
Expand Down Expand Up @@ -1045,15 +1029,15 @@ Resources:
AdjustmentType: PercentChangeInCapacity
MinAdjustmentMagnitude: 1
AutoScalingGroupName: !Ref AutoScalingGroup
Cooldown: 600
Cooldown: '600'
ScalingAdjustment: 25
ScaleDownPolicy:
Type: 'AWS::AutoScaling::ScalingPolicy'
Properties:
AdjustmentType: PercentChangeInCapacity
MinAdjustmentMagnitude: 1
AutoScalingGroupName: !Ref AutoScalingGroup
Cooldown: 600
Cooldown: '600'
ScalingAdjustment: -25
ContainerInstancesShortageAlarm:
Type: 'AWS::CloudWatch::Alarm'
Expand Down Expand Up @@ -1103,7 +1087,7 @@ Resources:
EvaluationPeriods: 1
Threshold: 90
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
CPUUtilizationTooHighAlarm:
Condition: HasAlertTopic
Type: 'AWS::CloudWatch::Alarm'
Expand All @@ -1120,7 +1104,7 @@ Resources:
EvaluationPeriods: 1
Threshold: 80
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
MemoryReservationTooHighAlarm:
Condition: HasAlertTopic
Type: 'AWS::CloudWatch::Alarm'
Expand All @@ -1137,7 +1121,7 @@ Resources:
EvaluationPeriods: 1
Threshold: 90
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
MemoryUtilizationTooHighAlarm:
Condition: HasAlertTopic
Type: 'AWS::CloudWatch::Alarm'
Expand All @@ -1154,7 +1138,7 @@ Resources:
EvaluationPeriods: 1
Threshold: 80
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
# scaling based on SchedulableContainers is described in detail here: http://garbe.io/blog/2017/04/12/a-better-solution-to-ecs-autoscaling/
SchedulableContainersRule:
Type: 'AWS::Events::Rule'
Expand All @@ -1181,7 +1165,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: RuleName
Value: !Ref SchedulableContainersRule
Expand All @@ -1206,7 +1190,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: RuleName
Value: !Ref SchedulableContainersCron
Expand Down Expand Up @@ -1347,7 +1331,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: FunctionName
Value: !Ref SchedulableContainersLambdaV2
Expand All @@ -1364,7 +1348,7 @@ Resources:
ComparisonOperator: GreaterThanThreshold
Threshold: 0
AlarmActions:
- 'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
Dimensions:
- Name: FunctionName
Value: !Ref SchedulableContainersLambdaV2
Expand Down Expand Up @@ -1406,8 +1390,7 @@ Outputs:
Name: !Sub '${AWS::StackName}-CanonicalHostedZoneID'
VPC:
Description: 'VPC of ECS cluster.'
Value:
'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'
Value: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
Export:
Name: !Sub '${AWS::StackName}-VPC'
SecurityGroup:
Expand Down
Loading

0 comments on commit af42548

Please sign in to comment.