Skip to content

Commit

Permalink
handle long resource_prefixes in role names
Browse files Browse the repository at this point in the history
  • Loading branch information
jillr committed Jun 1, 2021
1 parent 87e0646 commit 71cf248
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,6 @@ def change_instance_state(filters, desired_state, ec2):
unchanged = set()
failure_reason = ""

# TODO: better check_moding in here https://github.com/ansible-collections/community.aws/issues/16
for inst in instances:
try:
if desired_state == 'TERMINATED':
Expand Down Expand Up @@ -1611,8 +1610,6 @@ def handle_existing(existing_matches, changed, ec2, state):
elif state in ('restarted', 'rebooted'):
to_change_state = True
if to_change_state:
# TODO: this breaks check_mode, because change_instance_state handles checkmode but not ensure
# because ensure passes off to change...
state_results = ensure_instance_state(state, ec2)

changes = diff_instance_and_params(existing_matches[0], module.params, ec2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ subnet_b_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.33.0/24'
subnet_b_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.33.'
first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
image_id: "{{ ec2_ami_image }}"
security_groups: "{{ sg.group_id }}"
instance_type: "{{ ec2_instance_type }}"
instance_role: "ansible-test-sts-{{ resource_prefix }}-test-policy"
instance_role: "ansible-test-sts-{{ unique_id }}-test-policy"
vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
Expand Down

0 comments on commit 71cf248

Please sign in to comment.