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

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
主站蜘蛛池模板: 阿巴嘎旗| 广灵县| 蛟河市| 敖汉旗| 广灵县| 宾阳县| 临武县| 蒙城县| 大城县| 奎屯市| 隆子县| 探索| 洛隆县| 沂水县| 沙河市| 桐乡市| 三明市| 确山县| 仁寿县| 长兴县| 嘉鱼县| 恭城| 盘山县| 南城县| 昔阳县| 缙云县| 高清| 南宫市| 山东| 佛坪县| 六盘水市| 闸北区| 青河县| 安义县| 富民县| 阜宁县| 大余县| 大化| 乐昌市| 连南| 汝南县|