Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #401 from ahenroid/garethr-avoid-region-clash-betw…
Browse files Browse the repository at this point in the history
…een-env-and-property

(CLOUD-184, CLOUD-205) Avoid ambiguity when using the AWS_REGION environment var
  • Loading branch information
zleslie authored Jan 24, 2017
2 parents 4724d43 + 4cc3c39 commit dab0a02
Show file tree
Hide file tree
Showing 36 changed files with 93 additions and 139 deletions.
9 changes: 3 additions & 6 deletions lib/puppet/type/cloudwatch_alarm.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:cloudwatch_alarm) do
@doc = 'Type representing an AWS CloudWatch Alarm.'

Expand Down Expand Up @@ -73,13 +75,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the instances.'
validate do |value|
fail 'region should not contain spaces' if value =~ /\s/
fail 'region should not be blank' if value == ''
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:dimensions, :array_matching => :all) do
Expand Down
8 changes: 2 additions & 6 deletions lib/puppet/type/ec2_autoscalinggroup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'
require 'puppet/property/boolean'

Puppet::Type.newtype(:ec2_autoscalinggroup) do
Expand Down Expand Up @@ -87,13 +88,8 @@
desc 'Indicates whether newly launched instances are protected from termination by Auto Scaling when scaling in.'
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the instances.'
validate do |value|
fail 'region should not contain spaces' if value =~ /\s/
fail 'region should not be blank' if value == ''
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:launch_configuration) do
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet/type/ec2_elastic_ip.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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."

Expand All @@ -19,12 +21,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The name of the region in which the Elastic IP is found.'
validate do |value|
fail 'region should be a String' unless value.is_a?(String)
fail 'You must provide a region for Elastic IPs.' if value.nil? || value.empty?
end
end

newproperty(:instance) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_instance.rb
Original file line number Diff line number Diff line change
@@ -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.'
Expand Down Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions lib/puppet/type/ec2_launchconfiguration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_launchconfiguration) do
@doc = 'Type representing an EC2 launch configuration.'

Expand Down Expand Up @@ -33,13 +35,8 @@ def insync?(is)
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the instances.'
validate do |value|
fail 'region should not contain spaces' if value =~ /\s/
fail 'region should not be blank' if value == ''
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:instance_type) do
Expand Down
9 changes: 3 additions & 6 deletions lib/puppet/type/ec2_scalingpolicy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_scalingpolicy) do
@doc = 'Type representing an EC2 scaling policy.'

Expand All @@ -21,13 +23,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the policy.'
validate do |value|
fail 'region should not contain spaces' if value =~ /\s/
fail 'region should not be blank' if value == ''
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:adjustment_type) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_securitygroup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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
Expand All @@ -14,12 +15,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'the region in which to launch the security group'
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(:ingress, :array_matching => :all) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -13,12 +14,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the VPC.'
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(:cidr_block) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_customer_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand Down Expand Up @@ -31,12 +32,8 @@
desc 'The tags for the customer gateway.'
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the customer gateway.'
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(:type) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_dhcp_options.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -17,12 +18,8 @@
desc 'Tags for the DHCP option set.'
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to assign the DHCP option set.'
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(:domain_name, :array_matching => :all) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_internet_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -17,12 +18,8 @@
desc 'Tags to assign to the internet gateway.'
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the internet gateway.'
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(:vpc) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_routetable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -20,12 +21,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'Region in which to launch the route table.'
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(:routes, :array_matching => :all) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_subnet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -20,12 +21,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the subnet.'
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(:cidr_block) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_vpn.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand Down Expand Up @@ -53,12 +54,8 @@ def insync?(is)
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the VPN.'
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(:tags, :parent => PuppetX::Property::AwsTag) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_vpc_vpn_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -24,12 +25,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the VPN gateway.'
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

newparam(:availability_zone) do
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/elb_loadbalancer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.'
Expand All @@ -13,12 +14,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the load balancer.'
validate do |value|
fail 'region must not contain spaces' if value =~ /\s/
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:listeners, :array_matching => :all) do
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_db_parameter_group.rb
Original file line number Diff line number Diff line change
@@ -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.'

Expand All @@ -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
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_db_securitygroup.rb
Original file line number Diff line number Diff line change
@@ -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.'

Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_instance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:rds_instance) do
@doc = 'Type representing an RDS instance.'

Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit dab0a02

Please sign in to comment.