diff --git a/lib/puppet/type/cloudwatch_alarm.rb b/lib/puppet/type/cloudwatch_alarm.rb index 9c00fafa..c236ebc1 100644 --- a/lib/puppet/type/cloudwatch_alarm.rb +++ b/lib/puppet/type/cloudwatch_alarm.rb @@ -1,4 +1,4 @@ -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:cloudwatch_alarm) do @doc = 'Type representing an AWS CloudWatch Alarm.' diff --git a/lib/puppet/type/ec2_autoscalinggroup.rb b/lib/puppet/type/ec2_autoscalinggroup.rb index 2b343886..8856a756 100644 --- a/lib/puppet/type/ec2_autoscalinggroup.rb +++ b/lib/puppet/type/ec2_autoscalinggroup.rb @@ -1,5 +1,5 @@ require_relative '../../puppet_x/puppetlabs/property/tag.rb' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/region.rb' require 'puppet/property/boolean' Puppet::Type.newtype(:ec2_autoscalinggroup) do diff --git a/lib/puppet/type/ec2_elastic_ip.rb b/lib/puppet/type/ec2_elastic_ip.rb index 29aed019..d45a5d53 100644 --- a/lib/puppet/type/ec2_elastic_ip.rb +++ b/lib/puppet/type/ec2_elastic_ip.rb @@ -1,4 +1,4 @@ -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_elastic_ip) do @doc = "Type representing an Elastic IP and it's association." diff --git a/lib/puppet/type/ec2_instance.rb b/lib/puppet/type/ec2_instance.rb index 96125b78..95008287 100644 --- a/lib/puppet/type/ec2_instance.rb +++ b/lib/puppet/type/ec2_instance.rb @@ -1,4 +1,5 @@ require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_instance) do @doc = 'Type representing an EC2 instance.' @@ -93,12 +94,8 @@ def insync?(is) end end - newproperty(:region) do + newproperty(:region, :parent => PuppetX::Property::AwsRegion) do desc 'The region in which to launch the instance.' - validate do |value| - fail 'region should not contain spaces' if value =~ /\s/ - fail 'region should be a String' unless value.is_a?(String) - end end newproperty(:image_id) do diff --git a/lib/puppet/type/ec2_launchconfiguration.rb b/lib/puppet/type/ec2_launchconfiguration.rb index 839a0f6b..a490d10f 100644 --- a/lib/puppet/type/ec2_launchconfiguration.rb +++ b/lib/puppet/type/ec2_launchconfiguration.rb @@ -1,4 +1,4 @@ -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_launchconfiguration) do @doc = 'Type representing an EC2 launch configuration.' diff --git a/lib/puppet/type/ec2_scalingpolicy.rb b/lib/puppet/type/ec2_scalingpolicy.rb index 922c22ca..32511be3 100644 --- a/lib/puppet/type/ec2_scalingpolicy.rb +++ b/lib/puppet/type/ec2_scalingpolicy.rb @@ -1,4 +1,4 @@ -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_scalingpolicy) do @doc = 'Type representing an EC2 scaling policy.' diff --git a/lib/puppet/type/ec2_securitygroup.rb b/lib/puppet/type/ec2_securitygroup.rb index 5587c462..1ef502fd 100644 --- a/lib/puppet/type/ec2_securitygroup.rb +++ b/lib/puppet/type/ec2_securitygroup.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' require_relative '../../puppet_x/puppetlabs/aws_ingress_rules_parser' Puppet::Type.newtype(:ec2_securitygroup) do diff --git a/lib/puppet/type/ec2_vpc.rb b/lib/puppet/type/ec2_vpc.rb index f8c1f14a..7221969f 100644 --- a/lib/puppet/type/ec2_vpc.rb +++ b/lib/puppet/type/ec2_vpc.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc) do @doc = 'A type representing an AWS VPC.' diff --git a/lib/puppet/type/ec2_vpc_customer_gateway.rb b/lib/puppet/type/ec2_vpc_customer_gateway.rb index 42aeaf8a..f9721056 100644 --- a/lib/puppet/type/ec2_vpc_customer_gateway.rb +++ b/lib/puppet/type/ec2_vpc_customer_gateway.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_customer_gateway) do @doc = 'Type representing an AWS VPC customer gateways.' diff --git a/lib/puppet/type/ec2_vpc_dhcp_options.rb b/lib/puppet/type/ec2_vpc_dhcp_options.rb index f4ace4fe..f504ad7f 100644 --- a/lib/puppet/type/ec2_vpc_dhcp_options.rb +++ b/lib/puppet/type/ec2_vpc_dhcp_options.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_dhcp_options) do @doc = 'Type representing a DHCP option set for AWS VPC.' diff --git a/lib/puppet/type/ec2_vpc_internet_gateway.rb b/lib/puppet/type/ec2_vpc_internet_gateway.rb index 423d31a4..7ef6fb67 100644 --- a/lib/puppet/type/ec2_vpc_internet_gateway.rb +++ b/lib/puppet/type/ec2_vpc_internet_gateway.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_internet_gateway) do @doc = 'Type representing an EC2 VPC Internet Gateway.' diff --git a/lib/puppet/type/ec2_vpc_routetable.rb b/lib/puppet/type/ec2_vpc_routetable.rb index c576613c..4fdeb4f0 100644 --- a/lib/puppet/type/ec2_vpc_routetable.rb +++ b/lib/puppet/type/ec2_vpc_routetable.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_routetable) do @doc = 'Type representing a VPC route table.' diff --git a/lib/puppet/type/ec2_vpc_subnet.rb b/lib/puppet/type/ec2_vpc_subnet.rb index f2d1acf8..86c8f73f 100644 --- a/lib/puppet/type/ec2_vpc_subnet.rb +++ b/lib/puppet/type/ec2_vpc_subnet.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_subnet) do @doc = 'Type representing a VPC Subnet.' diff --git a/lib/puppet/type/ec2_vpc_vpn.rb b/lib/puppet/type/ec2_vpc_vpn.rb index 10806a81..c4822a24 100644 --- a/lib/puppet/type/ec2_vpc_vpn.rb +++ b/lib/puppet/type/ec2_vpc_vpn.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_vpn) do @doc = 'Type representing an AWS Virtual Private Networks.' diff --git a/lib/puppet/type/ec2_vpc_vpn_gateway.rb b/lib/puppet/type/ec2_vpc_vpn_gateway.rb index 22e56eaf..d9ef918a 100644 --- a/lib/puppet/type/ec2_vpc_vpn_gateway.rb +++ b/lib/puppet/type/ec2_vpc_vpn_gateway.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:ec2_vpc_vpn_gateway) do @doc = 'A type representing a VPN gateway.' diff --git a/lib/puppet/type/elb_loadbalancer.rb b/lib/puppet/type/elb_loadbalancer.rb index 000a1822..970aa249 100644 --- a/lib/puppet/type/elb_loadbalancer.rb +++ b/lib/puppet/type/elb_loadbalancer.rb @@ -1,5 +1,5 @@ -require_relative '../../puppet_x/puppetlabs/property/tag' -require_relative '../../puppet_x/puppetlabs/property/region' +require_relative '../../puppet_x/puppetlabs/property/tag.rb' +require_relative '../../puppet_x/puppetlabs/property/region.rb' Puppet::Type.newtype(:elb_loadbalancer) do @doc = 'Type representing an ELB load balancer.' diff --git a/lib/puppet/type/rds_db_parameter_group.rb b/lib/puppet/type/rds_db_parameter_group.rb index dd013a5c..a286c099 100644 --- a/lib/puppet/type/rds_db_parameter_group.rb +++ b/lib/puppet/type/rds_db_parameter_group.rb @@ -1,3 +1,5 @@ +require_relative '../../puppet_x/puppetlabs/property/region.rb' + Puppet::Type.newtype(:rds_db_parameter_group) do @doc = 'Type representing an RDS DB Parameter group.' @@ -22,12 +24,8 @@ end end - newproperty(:region) do + newproperty(:region, :parent => PuppetX::Property::AwsRegion) do desc 'The region in which to create the db_parameter_group.' - validate do |value| - fail 'region should be a String' unless value.is_a?(String) - fail 'region should not contain spaces' if value =~ /\s/ - end end end diff --git a/lib/puppet/type/rds_db_securitygroup.rb b/lib/puppet/type/rds_db_securitygroup.rb index 42bc4831..703c202a 100644 --- a/lib/puppet/type/rds_db_securitygroup.rb +++ b/lib/puppet/type/rds_db_securitygroup.rb @@ -1,3 +1,5 @@ +require_relative '../../puppet_x/puppetlabs/property/region.rb' + Puppet::Type.newtype(:rds_db_securitygroup) do @doc = 'Type representing an RDS instance.' @@ -32,12 +34,8 @@ end end - newproperty(:region) do + newproperty(:region, :parent => PuppetX::Property::AwsRegion) do desc 'The region in which to create the db_securitygroup.' - validate do |value| - fail 'region should be a String' unless value.is_a?(String) - fail 'region should not contain spaces' if value =~ /\s/ - end end newproperty(:ip_ranges, :array_matching => :all) do diff --git a/lib/puppet/type/rds_instance.rb b/lib/puppet/type/rds_instance.rb index 6e8ea4b1..6c65e196 100644 --- a/lib/puppet/type/rds_instance.rb +++ b/lib/puppet/type/rds_instance.rb @@ -1,3 +1,5 @@ +require_relative '../../puppet_x/puppetlabs/property/region.rb' + Puppet::Type.newtype(:rds_instance) do @doc = 'Type representing an RDS instance.' @@ -49,12 +51,8 @@ Not applicable. Must be null.' end - newproperty(:region) do + newproperty(:region, :parent => PuppetX::Property::AwsRegion) do desc 'The region in which to launch the instance.' - validate do |value| - fail 'region should be a String' unless value.is_a?(String) - fail 'region should not contain spaces' if value =~ /\s/ - end end newproperty(:db_instance_class) do diff --git a/lib/puppet/type/sqs_queue.rb b/lib/puppet/type/sqs_queue.rb index dc72d9b3..2f4fa054 100644 --- a/lib/puppet/type/sqs_queue.rb +++ b/lib/puppet/type/sqs_queue.rb @@ -1,3 +1,5 @@ +require_relative '../../puppet_x/puppetlabs/property/region.rb' + Puppet::Type.newtype(:sqs_queue) do @doc = "Type representing a SQS Queue" ensurable @@ -43,13 +45,8 @@ munge(&:to_s) end - newproperty(:region) do + newproperty(:region, :parent => PuppetX::Property::AwsRegion) do desc 'The name of the region in which the SQS queue is located' - validate do |value| - fail 'region should be a String' unless value.is_a?(String) - fail 'You must provide a non-blank region name for SQS Queues' if value.nil? || value.empty? - fail 'The name of a region should contain only alphanumeric characters or dashes' unless value =~ /^([a-zA-Z]+-+)+\d$/ - end end newproperty(:visibility_timeout) do diff --git a/spec/unit/provider/rds_instance/v2_spec.rb b/spec/unit/provider/rds_instance/v2_spec.rb index b081b1c2..c98537d7 100644 --- a/spec/unit/provider/rds_instance/v2_spec.rb +++ b/spec/unit/provider/rds_instance/v2_spec.rb @@ -12,7 +12,7 @@ Puppet::Type.type(:rds_instance).new( ensure: 'present', name: 'awesome-db-5', - region: 'us-west-1', + region: 'sa-east-1', db_name: 'mysqldbname3', engine: 'mysql', engine_version: '5.6.19a', diff --git a/spec/unit/type/sqs_queue_spec.rb b/spec/unit/type/sqs_queue_spec.rb index ab631385..f614d1ff 100644 --- a/spec/unit/type/sqs_queue_spec.rb +++ b/spec/unit/type/sqs_queue_spec.rb @@ -29,46 +29,46 @@ end it 'should create a valid instance' do - type_class.new({name: 'name', region: 'us-east-1'}) + type_class.new({name: 'name', region: 'sa-east-1'}) end it 'should set delay seconds should get set with a valid value' do - queue = type_class.new({name: 'queue', region: 'us-east-1', delay_seconds: 450}) + queue = type_class.new({name: 'queue', region: 'sa-east-1', delay_seconds: 450}) expect(queue[:delay_seconds]).to eq("450") end it 'delay seconds should default to 0' do - queue = type_class.new({name: 'queue', region: 'us-east-1'}) + queue = type_class.new({name: 'queue', region: 'sa-east-1'}) expect(queue[:delay_seconds]).to eq("0") end it 'visibility_timeout should default to 30' do - queue = type_class.new({name: 'queue', region: 'us-east-1'}) + queue = type_class.new({name: 'queue', region: 'sa-east-1'}) expect(queue[:visibility_timeout]).to eq('30') end it 'should set visibility_timeout with a valid value' do - queue = type_class.new({name: 'queue', region: 'us-east-1', visibility_timeout: 123}) + queue = type_class.new({name: 'queue', region: 'sa-east-1', visibility_timeout: 123}) expect(queue[:visibility_timeout]).to eq("123") end it 'should set message_retention_period should get set with a valid value' do - queue = type_class.new({name: 'queue', region: 'us-east-1', message_retention_period: 360}) + queue = type_class.new({name: 'queue', region: 'sa-east-1', message_retention_period: 360}) expect(queue[:message_retention_period]).to eq("360") end it 'should set message_retention_period to default to 345600' do - queue = type_class.new({name: 'queue', region: 'us-east-1'}) + queue = type_class.new({name: 'queue', region: 'sa-east-1'}) expect(queue[:message_retention_period]).to eq("345600") end it 'should set maximum_message_size should get set with a valid value' do - queue = type_class.new({name: 'queue', region: 'us-east-1', maximum_message_size: 2048}) + queue = type_class.new({name: 'queue', region: 'sa-east-1', maximum_message_size: 2048}) expect(queue[:maximum_message_size]).to eq("2048") end it 'should set maximum_message_size to default to 262144' do - queue = type_class.new({name: 'queue', region: 'us-east-1'}) + queue = type_class.new({name: 'queue', region: 'sa-east-1'}) expect(queue[:maximum_message_size]).to eq("262144") end @@ -81,26 +81,23 @@ context 'erroring values' do it 'should error with incorrect range value for delay seconds' do expect do - type_class.new({name: 'queue', region: 'us-east-1', delay_seconds: 1024}) + type_class.new({name: 'queue', region: 'sa-east-1', delay_seconds: 1024}) end.to raise_error(Puppet::Error, /delay_seconds must be an integer between 0 and 900/) end it 'should require something that looks like a region' do expect do - type_class.new ({name: 'somename', :region => 'us_east_1'}) - end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/) + type_class.new ({name: 'somename', :region => 'sa-east-1 '}) + end.to raise_error(Puppet::Error, /region should not contain spaces/) expect do - type_class.new ({name: 'somename', :region => '123'}) - end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/) - expect do - type_class.new ({name: 'somename', :region => 'europe'}) - end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/) + type_class.new ({name: 'somename', :region => 1}) + end.to raise_error(Puppet::Error, /region should be a String/) end it 'should require a non-blank region' do expect do type_class.new ({name: 'somename', region: ''}) - end.to raise_error(Puppet::Error, /You must provide a non-blank region name for SQS Queues/) + end.to raise_error(Puppet::Error, /region should not be blank/) end it 'should require a name' do expect do