Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for ephemeral 0-23 in E2504 #1260

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cfnlint/rules/resources/ectwo/Ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def match(self, cfn):
ebs = properties.get('Ebs')
if virtual_name:
# switch to regex
if not re.match(r'^ephemeral[0-9]$', virtual_name):
if not re.match(r'^ephemeral([0-9]|[1][0-9]|[2][0-3])$', virtual_name):
pathmessage = path[:] + [index, 'VirtualName']
message = 'Property VirtualName should be of type ephemeral(n) for {0}'
matches.append(
Expand Down
57 changes: 57 additions & 0 deletions test/fixtures/templates/bad/resources/ec2/ebs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
## Missing Properties
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-2f726546"
InstanceType: t1.micro
KeyName: 1
BlockDeviceMappings:
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 0
DeleteOnTermination: false
VolumeSize: 20
- DeviceName: /dev/sdn
Ebs:
VolumeType: magnetic
Iops: 100
DeleteOnTermination: false
VolumeSize: 20
NetworkInterfaces:
- DeviceIndex: "1"
MyEC2Instance3:
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-2f726546"
BlockDeviceMappings:
- DeviceName: /dev/sdm
VirtualName: ephemeralA
- DeviceName: /dev/sdn
VirtualName: ephemeral0
- DeviceName: /dev/sdo
VirtualName: ephemeral24
- DeviceName: /dev/sdo
VirtualName: ephemeral100
MyLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: "ami-2f726546"
InstanceType: t2.micro
BlockDeviceMappings:
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 10
DeleteOnTermination: false
VolumeSize: 20
- DeviceName: /dev/sdn
Ebs:
VolumeType: standard
Iops: 100
DeleteOnTermination: false
VolumeSize: 20
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Resources:
InstanceType: t1.micro
KeyName: 1
BlockDeviceMappings:
-
DeviceName: /dev/sdm
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: 1000
Expand All @@ -28,24 +27,25 @@ Resources:
Properties:
ImageId: "ami-2f726546"
BlockDeviceMappings:
-
DeviceName: /dev/sdm
VirtualName: ephemeral0
- DeviceName: /dev/sdm
VirtualName: ephemeral0
- DeviceName: /dev/sdn
VirtualName: ephemeral23
- DeviceName: /dev/sdo
VirtualName: ephemeral19
MyLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: "ami-2f726546"
InstanceType: t2.micro
BlockDeviceMappings:
-
DeviceName: /dev/sdm
- DeviceName: /dev/sdm
Ebs:
VolumeType: io1
Iops: !Ref myIops
DeleteOnTermination: false
VolumeSize: 20
-
DeviceName: /dev/sdn
- DeviceName: /dev/sdn
Ebs:
VolumeType: standard
DeleteOnTermination: false
Expand Down
5 changes: 4 additions & 1 deletion test/unit/rules/resources/ec2/test_ec2_ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ def setUp(self):
"""Setup"""
super(TestPropertyEc2Ebs, self).setUp()
self.collection.register(Ebs())
self.success_templates = [
'test/fixtures/templates/good/resources/ec2/ebs.yaml',
]

def test_file_positive(self):
"""Test Positive"""
self.helper_file_positive()

def test_file_negative(self):
"""Test failure"""
self.helper_file_negative('test/fixtures/templates/bad/properties_ebs.yaml', 3)
self.helper_file_negative('test/fixtures/templates/bad/resources/ec2/ebs.yaml', 5)