mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-15 09:13:01 +02:00
Support for associating to existing AWS Elastic IP
Signed-off-by: Elliot Murphy <statik@users.noreply.github.com>
This commit is contained in:
parent
5981bb9cad
commit
1e2c8f39ff
4 changed files with 43 additions and 2 deletions
|
@ -1 +1 @@
|
||||||
ansible==2.5.2
|
ansible==2.6.11
|
||||||
|
|
|
@ -11,6 +11,12 @@ Parameters:
|
||||||
Type: String
|
Type: String
|
||||||
WireGuardPort:
|
WireGuardPort:
|
||||||
Type: String
|
Type: String
|
||||||
|
UseThisElasticIP:
|
||||||
|
Type: String
|
||||||
|
Default: ''
|
||||||
|
Conditions:
|
||||||
|
AllocateNewEIP: !Equals [!Ref UseThisElasticIP, '']
|
||||||
|
AssociateExistingEIP: !Not [!Equals [!Ref UseThisElasticIP, '']]
|
||||||
Resources:
|
Resources:
|
||||||
VPC:
|
VPC:
|
||||||
Type: AWS::EC2::VPC
|
Type: AWS::EC2::VPC
|
||||||
|
@ -187,6 +193,7 @@ Resources:
|
||||||
|
|
||||||
ElasticIP:
|
ElasticIP:
|
||||||
Type: AWS::EC2::EIP
|
Type: AWS::EC2::EIP
|
||||||
|
Condition: AllocateNewEIP
|
||||||
Properties:
|
Properties:
|
||||||
Domain: vpc
|
Domain: vpc
|
||||||
InstanceId: !Ref EC2Instance
|
InstanceId: !Ref EC2Instance
|
||||||
|
@ -194,6 +201,14 @@ Resources:
|
||||||
- EC2Instance
|
- EC2Instance
|
||||||
- VPCGatewayAttachment
|
- VPCGatewayAttachment
|
||||||
|
|
||||||
|
ElasticIPAssociation:
|
||||||
|
Type: AWS::EC2::EIPAssociation
|
||||||
|
Condition: AssociateExistingEIP
|
||||||
|
Properties:
|
||||||
|
AllocationId: !Ref UseThisElasticIP
|
||||||
|
InstanceId: !Ref EC2Instance
|
||||||
|
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
ElasticIP:
|
ElasticIP:
|
||||||
Value: !Ref ElasticIP
|
Value: !GetAtt [EC2Instance, PublicIp]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
PublicSSHKeyParameter: "{{ lookup('file', SSH_keys.public) }}"
|
PublicSSHKeyParameter: "{{ lookup('file', SSH_keys.public) }}"
|
||||||
ImageIdParameter: "{{ ami_image }}"
|
ImageIdParameter: "{{ ami_image }}"
|
||||||
WireGuardPort: "{{ wireguard_port }}"
|
WireGuardPort: "{{ wireguard_port }}"
|
||||||
|
UseThisElasticIP: "{{ use_existing_eip }}"
|
||||||
tags:
|
tags:
|
||||||
Environment: Algo
|
Environment: Algo
|
||||||
register: stack
|
register: stack
|
||||||
|
|
|
@ -53,3 +53,28 @@
|
||||||
[{{ default_region }}]
|
[{{ default_region }}]
|
||||||
register: _algo_region
|
register: _algo_region
|
||||||
when: region is undefined
|
when: region is undefined
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Get existing available Elastic IPs
|
||||||
|
ec2_eip_facts:
|
||||||
|
register: raw_eip_addresses
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
available_eip_addresses: "{{ raw_eip_addresses.addresses | selectattr('association_id', 'undefined') | list }}"
|
||||||
|
|
||||||
|
- pause:
|
||||||
|
prompt: |
|
||||||
|
Do you want to use a pre-allocated Elastic IP?
|
||||||
|
(leave blank to allocate a new IP)
|
||||||
|
{% for eip in available_eip_addresses %}
|
||||||
|
{{ loop.index }}. {{ eip['public_ip'] }}
|
||||||
|
{% endfor %}
|
||||||
|
['']
|
||||||
|
register: _use_existing_eip
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
use_existing_eip: >-
|
||||||
|
{% if _use_existing_eip.user_input is defined and _algo_region.user_input != "" %}
|
||||||
|
{{ available_eip_addresses[_use_existing_eip.user_input | int -1 ]['allocation_id'] }}
|
||||||
|
{%- else %}{% endif %}
|
||||||
|
when: use_existing_eip is undefined
|
Loading…
Add table
Reference in a new issue