官术网_书友最值得收藏!

How to do it...

We can create a security group, using an ec2_group module, this will take the VPC ID, the region, and rules as input.
Let's create a task for a security group:

---
- name: Create EC2 Security Group
ec2_group:
name: my_first_sg
description: A sample security group webservers
vpc_id: "{{ my_first_vpc.vpc.id }}"
region: "{{ aws_region }}"
aws_secret_key: "{{ secret_key }}"
aws_access_key: "{{ access_key }}"
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: "{{ vpc_cidr_block }}"
- proto: tcp
from_port: 443
to_port: 443
cidr_ip: 0.0.0.0/0
- proto: icmp
from_port: 8
to_port: -1
cidr_ip: "{{ vpc_cidr_block }}"
rules_egress:
- proto: all
cidr_ip: 0.0.0.0/0
register: my_first_sg
主站蜘蛛池模板: 德州市| 松阳县| 甘洛县| 古浪县| 厦门市| 墨脱县| 六盘水市| 云浮市| 乐安县| 陇西县| 长岛县| 新宁县| 南和县| 清水河县| 赤水市| 蓬溪县| 城固县| 辽阳县| 泗洪县| 长武县| 当涂县| 长兴县| 汕尾市| 广汉市| 柳河县| 恩施市| 江城| 阳高县| 邯郸市| 名山县| 吴堡县| 宜君县| 天全县| 荆门市| 育儿| 嘉义县| 蓝田县| 清远市| 黎川县| 新乡市| 云安县|