Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GomathiselviS committed Dec 13, 2024
1 parent 3be52b5 commit 98ac9a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 12 additions & 1 deletion extensions/patterns/configure_ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ This pattern is designed to help get an EC2 instance up and running.

To enable SSH access to the EC2 instance from your local machine, you need to do 2 things:

1. **Provide a Key Name**: Enter a key name in the **key_name** parameter in the survey. A new key will be created (or an existing key with the specified namewill be used) and associated with the EC2 instance. Be sure to save the private key value provided at the end of the job run, as you'll need it for future access to the instance.
1. **Provide a Key Name**: Enter a key name in the **key_name** parameter in the survey. A new key will be created (or an existing key with the specified namewill be used) and associated with the EC2 instance. If creating a new key pair, be sure to save the private key value provided at the end of the job run, as you'll need it for future access to the instance.

2. **Add a Security Group Rule for SSH Access**: Configure a security group rule to allow inbound SSH traffic from your local machine's IP address. Provide this rule in the **sg_rules** parameter in the survey.

_Sample Security Group Rule_
---------------------------

```yaml
sg_rules:
- proto: tcp
ports: 22
cidr_ip: 203.0.113.0/3
```
## What This Pattern Covers
### Projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- name: Set manage_ec2_instance_key_name role var
ansible.builtin.set_fact:
manage_ec2_instance_key_name: "{{ key_name }}"
when: key_name is defined
when: key_name is defined and key_name != ''

- name: Get RHEL 9 AMI ID if needed
when: ami_id | default("", true) == ""
Expand All @@ -33,7 +33,7 @@
- name: Update ami_id variable
ansible.builtin.set_fact:
ami_id: "{{ (images.images | sort(attribute='name') | last).image_id }}"

- name: Create networking resources
ansible.builtin.include_role:
name: cloud.aws_ops.ec2_networking_resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,3 @@
msg:
- "EC2 instance {{ ec2_instance.instance_ids[0] }} created successfully"
- "Instance details: {{ ec2_instance_manage_create_result.instances[0] }}"

- name: Output private key if a new keypair was created
when: ec2_instance_manage_key_pair_result.key is defined
ansible.builtin.debug:
msg: "A new key pair was created for ssh access to the instance. Please save this private key for reference: {{ ec2_instance_manage_key_pair_result.key.private_key }}"

0 comments on commit 98ac9a5

Please sign in to comment.