Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
d3c369c
Add fix for using ec2_launchconfiguration with existing configs but n…
MWilkinson Nov 14, 2016
82a7173
Merge branch 'master' of https://github.com/puppetlabs/puppetlabs-aws
MWilkinson Jan 19, 2017
44d9f85
Merge branch 'master' of https://github.com/puppetlabs/puppetlabs-aws
MWilkinson Mar 21, 2017
4b9f200
initial work adding elbv2 loadbalancer and targetgroup
MWilkinson Dec 13, 2016
6ae92a7
add missing Boolean require
MWilkinson Dec 14, 2016
dc5c519
add create/delete functionality
MWilkinson Dec 22, 2016
b2800e0
destroy now working,
MWilkinson Dec 24, 2016
8ce1b2f
add tag setting/updating
MWilkinson Dec 27, 2016
6009576
populate targetgroup resource on prefetch, initial get instance for e…
MWilkinson Dec 28, 2016
6a8d26e
add target groups and certificate info to elbv2 information
MWilkinson Jan 19, 2017
7ea1652
initial work adding elbv2 loadbalancer and targetgroup
MWilkinson Dec 13, 2016
f8b5392
destroy now working,
MWilkinson Dec 24, 2016
2874aec
add tag setting/updating
MWilkinson Dec 27, 2016
7ff81ff
populate targetgroup resource on prefetch, initial get instance for e…
MWilkinson Dec 28, 2016
0751118
add target groups and certificate info to elbv2 information
MWilkinson Jan 19, 2017
bd20a97
Update the Gemfile and .travis.yml
DavidS Nov 19, 2016
509aee4
Designate former 'tests' files as examples
DavidS Dec 1, 2016
dd93f6a
Attempt fix hash method call on nil object
Nov 28, 2016
f4dca98
Update the Gemfile for webmock ruby versions
Dec 15, 2016
d53d51a
Updated README.md to reflect that allocated_storage is a required par…
mikemarseglia Nov 16, 2016
6a6fa69
Bump the SDK gem version
Dec 19, 2016
fba03b2
add xenial to metadata
eputnam Jan 4, 2017
257c9a8
Add support for ELB listener modifications
Dec 13, 2016
b210472
Remove contradictory attribute descriptions.
dallinb Dec 15, 2016
57fef43
Fixed typo for ec2:DeleteDhcpOptions action in the policy.
dallinb Sep 17, 2016
70082e8
The ec2:AssociateDhcpOptions action is required in the policy to allo…
dallinb Sep 17, 2016
f3451bf
Modifying logic behind dhcp_options netbios validation
Oct 25, 2016
a3ab111
Update docs for #377
hunner Jan 12, 2017
26e82bd
Rds snapshot restore
Oct 19, 2016
3833719
early iam_role type and provider development
reubenavery Jul 26, 2016
fa8dc47
early iam instance profile type development
reubenavery Aug 2, 2016
b80ca1d
iam_role policy_document unescaping html escaped by what seems to be …
reubenavery Aug 3, 2016
a0985f0
finishing up iam_instance_profile type
reubenavery Aug 3, 2016
046b298
Updating README for iam_instance_profile
reubenavery Aug 5, 2016
e70cb6b
iam_role and iam_instance_profile: Changing secondary operation messa…
reubenavery Aug 5, 2016
cc836cd
Adding support for path prefixes to iam_role and iam_instance_profile
reubenavery Aug 9, 2016
93e976c
Add functionality to support elbv2 load balancers
MWilkinson Nov 14, 2016
f425ce6
(maint) Comment out iam acceptance tests
hunner Jan 12, 2017
ec8760e
Add refresh for Ecs_service resources
Jan 20, 2017
c43aa84
Add delete_on_termination and volume_type settings for the block_devi…
bengler9 Oct 13, 2015
788743c
Avoid ambiguity when using the AWS_REGION environment var
garethr Mar 24, 2015
df71b57
(CLOUD-184, CLOUD-205) Avoid ambiguity when using the AWS_REGION envi…
Jan 20, 2017
4b54530
Add initial support for CloudFront
Dec 16, 2016
e9b20e5
Allow security groups mutual peering
Jan 23, 2017
ec3192f
Support for managing EC2 Volumes
Feb 17, 2016
0664a53
Begin filtering sensitive data during VCR recording
Jan 10, 2017
9bf5d2e
Update tests for filtering changes
Jan 11, 2017
33372a2
Drop semantic require reference
Feb 2, 2017
10a2b45
Tags support for rds
Oct 19, 2016
9ad6ad3
Add support for CloudFormation.
dharmabruce Feb 6, 2017
df789cb
Begin KMS management
Jan 30, 2017
2eb339d
Allows specifying public and private ip address.
Jan 7, 2017
333ae1b
Fixed indentation, duplicate conditional, and added comments.
kmacoske Feb 10, 2017
2f08672
(MAINT) Minor fix for ELB acceptance tests
Feb 12, 2017
15c5a88
Enable autorequire for iam_role for policy attachment
Jan 30, 2017
c300262
Add role management for ECS tasks
Jan 31, 2017
c32a9ec
Remove print from IAM user provider
Jan 31, 2017
94dbe42
Begin ELB listener policy management
Jan 13, 2017
6b5f9d2
Remove the securitygroup autorequire
Feb 3, 2017
b6401af
Enable volume management for ECS tasks
Jan 31, 2017
28ff58b
Reduce log verbosity for iam_role
Mar 1, 2017
3bebc5a
Improve ELB listener detection
Mar 2, 2017
2576124
Add public DNS resolution and hostname properties to VPC
Mar 3, 2017
61a7602
Add support for private Route53 zones
Feb 22, 2017
c8ba03f
Minor update for README install instructions
Mar 4, 2017
868a075
created skeleton for the rds_db_subnet_group resource type
Oct 28, 2016
9b050b7
Working on tests
Nov 8, 2016
247744d
Looks like a typo here.
binford2k Mar 9, 2017
b6674f4
Add missing backtick in readme
Mar 13, 2017
46e7b05
Correct name of RDS tags property in readme
Mar 13, 2017
73cabf6
Look for truncated results on ecs_task_definition resources
Mar 7, 2017
367c8f6
Properly handle array of domain_name for ec2_vpc_dhcp_options
edestecd Mar 9, 2017
437ac62
Drop Puppet Enterprise from metadata
Mar 20, 2017
14a5c03
initial work adding elbv2 loadbalancer and targetgroup
MWilkinson Dec 13, 2016
891dff5
Merge branch 'parked/elbv2' of https://github.com/ctidigital/puppetla…
MWilkinson Mar 23, 2017
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
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ You can use the aws module to audit AWS resources, launch autoscaling groups in
* `ec2_securitygroup`: Sets up an EC2 security group.
* `ec2_volume`: Sets up an EC2 EBS volume.
* `elb_loadbalancer`: Sets up an ELB load balancer.
* `elbv2_loadbalancer`: Sets up an ELBv2 load balancer.
* `elbv2_targetgroup`: Sets up a ELBv2 target group.
* `cloudwatch_alarm`: Sets up a Cloudwatch Alarm.
* `ec2_autoscalinggroup`: Sets up an EC2 auto scaling group.
* `ec2_elastic_ip`: Sets up an Elastic IP and its association.
Expand Down Expand Up @@ -697,6 +699,83 @@ back- end instances. Accepts a hash with the following keys:
##### `snapshot_id`
*Optional* The snapshot from which to create the volume.

#### Type: elbv2_loadbalancer

#####`name`
*Required* The name of the load balancer. This is the value of the AWS Name tag.

#####`region`
*Required* The region in which to launch the target group. For valid values, see [AWS Regions](http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region).

#####`listeners`

#####`health_check`

#####`subnets`

#####`security_groups`

#####`scheme`
#####`instancs`
#####`availability_zones`
#####`dns_name`

#####`tags`
*Optional* The tags for the target group. This parameter is set at creation only; it is not affected by updates. Accepts a 'key => value' hash of tags.

#### Type: elbv2_targetgroup

#####`name`
*Required* The name of the target group. This is the value of the AWS Name tag.

#####`region`
*Required* The region in which to launch the target group. For valid values, see [AWS Regions](http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region).

#####`protocol`
*Required*

#####`port`
*Required*

#####`vpc`
*Required*

#####`health_check_success_codes`
*Optional*

#####`health_check_path`
*Optional*

#####`health_check_port`
*Optional*

#####`health_check_protocol`
*Optional*

#####`health_check_interval`
*Optional*

#####`health_check_timeout`
*Optional*

#####`healthy_threshold`
*Optional*

#####`unhealthy_threshold`
*Optional*

#####`deregistration_delay`
*Optional*

#####`stickiness`
*Optional*

#####`stickiness_duration`
*Optional*

#####`tags`
*Optional* The tags for the target group. This parameter is set at creation only; it is not affected by updates. Accepts a 'key => value' hash of tags.

#### Type: cloudwatch_alarm

##### `name`
Expand Down
200 changes: 200 additions & 0 deletions lib/puppet/provider/elbv2_loadbalancer/v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
require_relative '../../../puppet_x/puppetlabs/aws.rb'

Puppet::Type.type(:elbv2_loadbalancer).provide(:v2, :parent => PuppetX::Puppetlabs::Aws) do

confine feature: :aws

mk_resource_methods

def self.instances()
Puppet.debug("Fetching ELBv2 Load Balancers (instances)")
regions.collect do |region|
vpc_names = {}
vpc_response = ec2_client(region).describe_vpcs()
vpc_response.data.vpcs.each do |vpc|
vpc_name = name_from_tag(vpc)
vpc_names[vpc.vpc_id] = vpc_name if vpc_name
end

tg_names = {}
tg_response = elbv2_client(region).describe_target_groups()
tg_response.data.target_groups.each do |tg|
tg_names[tg.target_group_arn] = tg.target_group_name
end

cert_names = {}
cert_response = iam_client(region).list_server_certificates()
cert_response.data.server_certificate_metadata_list.each do |cert|
cert_names[cert.arn] = cert.server_certificate_name
end

load_balancers = []
elbs(region) do |elb|
load_balancers << new(load_balancer_to_hash(region, elb, vpc_names, tg_names, cert_names) )
end

load_balancers
end.flatten
end

def self.prefetch(resources)
instances.each do |prov|
Puppet.debug("Prefetching #{prov.name}")
if resource = resources[prov.name] # rubocop:disable Lint/AssignmentInCondition
if resource[:region] == prov.region
Puppet.debug("Updating resource for #{prov.name}")
resource.provider = prov
end
end
end
end

def self.elbs(region)
region_client = elbv2_client(region)

response = region_client.describe_load_balancers()
marker = response.next_marker

Puppet.debug(response)

response.load_balancers.each do |elb|
yield elb
end

while marker
response = region_client.describe_load_balancers( {
marker: marker
})
marker = response.next_marker
response.load_balancers.each do |elb|
yield elb
end
end
end

def self.listeners(region,lbarn)
Puppet.debug("listeners('#{region}','#{lbarn}')")
region_client = elbv2_client(region)

response = region_client.describe_listeners( {
load_balancer_arn: lbarn,
})
marker = response.next_marker

response.listeners.each do |listener|
yield listener
end

while marker
response = region_client.describe_listeners( {
marker: marker
})
marker = response.next_marker
response.listeners.each do |listener|
yield listener
end
end
end

def self.rules(region,lstnrarn)
Puppet.debug("rules('#{region}','#{lstnrarn}')")
region_client = elbv2_client(region)

response = region_client.describe_rules( {
listener_arn: lstnrarn,
})
response.rules.each do |rule|
next if rule.priority == 'default'
yield rule
end
end

def self.load_balancer_to_hash(region, elb, vpcs, tgs, certs)
Puppet.debug("vpc id: #{elb.vpc_id}, Vpcs: #{vpcs}")

elblisteners = [ ]
listeners(region, elb.load_balancer_arn) do |listener|
elblisteners << listener_to_hash(region, listener, tgs, certs)
end

Puppet.debug("Listeners: #{elblisteners}")

attributes = { }
tags = { }

{
ensure: :present,
name: elb.load_balancer_name,
arn: elb.load_balancer_arn,
region: region,
vpc: vpcs[elb.vpc_id],
scheme: elb.scheme,
listeners: elblisteners,
tags: tags,
}
end

def self.listener_to_hash(region, listener, tgs, certs)
Puppet.debug("listener_to_hash: #{listener}")

rules = [ ]
rules(region,listener.listener_arn) do |rule|
rules << rule_to_hash(rule,tgs)
end

lstnr = {
protocol: listener.protocol,
port: listener.port,
ssl_policy: listener.ssl_policy,
default_target_group: tgs[ listener.default_actions.first.target_group_arn ],
}
lstnr[:rules] = rules unless rules.empty?
lstnr[:certificate] = certs[listener.certificates.first.certificate_arn] unless listener.certificates.empty?

lstnr
end

def self.rule_to_hash(rule,tgs)
Puppet.debug("rule_to_hash: #{rule}")

rh = {
priority: rule.priority,
target_group: tgs[rule.actions.first.target_group_arn],
}

rh[:path_match] = rule.conditions.first.values.first unless rule.conditions.empty?

rh
end

def exists?
@property_hash[:ensure] == :present
end

def create
Puppet.debug("Creating load balancer #{name} in region #{target_region}")

elbv2 = elbv2_client(target_region)
ec2 = ec2_client(target_region)
ec2_response = ec2.describe_subnets()

config = {
load_balancer_name: name,

scheme: scheme.nil? ? scheme : :'internet-facing',
}

end

def destroy
Puppet.debug("Deleting load balancer #{name} in region #{target_region}")
elbv2 = elbv2_client(target_region)

Puppet.debug("Load Balancer Arn: ${@property_hash[:arn]}")

elbv2.delete_load_balancer({
load_balancer_arn: @property_hash[:arn],
})
@property_hash[:ensure] = :absent
end
end
Loading