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

Add iam_instance_profile to ec2_launchconfiguration #482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ A hint to specify the VPC. This is useful when detecting ambiguously named secur

This parameter is set at creation only; it is not affected by updates.

##### `iam_instance_profile`

Optional.

The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.

#### Type: ec2_scalingpolicy

##### `name`
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/provider/ec2_launchconfiguration/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.prefetch(resources)
end
end

read_only(:region, :image_id, :instance_type, :key_name, :security_groups)
read_only(:region, :image_id, :instance_type, :key_name, :security_groups, :iam_instance_profile)

def self.config_to_hash(region, config)
# It appears possible to get launch configurations manually to a state where
Expand Down Expand Up @@ -61,6 +61,7 @@ def self.config_to_hash(region, config)
region: region,
spot_price: config.spot_price,
ebs_optimized: config.ebs_optimized,
iam_instance_profile: config.iam_instance_profile,
}
if devices.empty?
config[:block_device_mappings] = [ ]
Expand Down Expand Up @@ -105,6 +106,7 @@ def create
security_groups: group_ids,
instance_type: resource[:instance_type],
user_data: data,
iam_instance_profile: resource[:iam_instance_profile],
}

key = resource[:key_name] ? resource[:key_name] : false
Expand Down
9 changes: 9 additions & 0 deletions lib/puppet/type/ec2_launchconfiguration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def set(value)
end
end

newproperty(:iam_instance_profile) do
desc 'The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.'
validate do |value|
fail 'instance_type should not contains spaces' if value =~ /\s/
fail 'instance_type should not be blank' if value == ''
fail 'instance_type should be a String' unless value.is_a?(String)
end
end

autorequire(:ec2_securitygroup) do
groups = self[:security_groups]
groups.is_a?(Array) ? groups : [groups]
Expand Down