-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-ec2.yml
42 lines (40 loc) · 1.47 KB
/
create-ec2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Create EC2
ec2_instance:
key_name: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/keyname', region='us-east-1') }}"
security_group: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ security_group }}', region='us-east-1') }}"
image_id: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ ami_type }}', region='us-east-1') }}"
instance_type: "{{ instance_type }}"
region: "us-east-1"
vpc_subnet_id: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ vpc_subnet_id }}', region='us-east-1') }}"
instance_role: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ instance_role }}', region='us-east-1') }}"
wait: true
volumes:
- device_name: /dev/xvda
ebs:
volume_type: gp2
volume_size: "{{ root_volume_size }}"
delete_on_termination: true
encrypted: true
name: "{{ instance_name }}"
tags:
created_by: "{{ created_by }}"
Owner: "{{ Owner }}"
App_Name: "{{ App_Name }}"
Cost_Center: "{{ Cost_Center }}"
Business_Unit: "{{ Business_Unit }}"
user_data: |
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
echo "<html><body><h1>Hello JJTech Team</h1></body></html>" > /var/www/html/index.html
# - debug:
# msg: ec2_instance
# - debug:
# msg: "{{ ec2.results[0].instance_ids }}"