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

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
主站蜘蛛池模板: 琼结县| 普兰县| 安宁市| 乌鲁木齐县| 邛崃市| 南开区| 木兰县| 绥德县| 利辛县| 洛扎县| 伊吾县| 南投市| 中阳县| 阳高县| 偏关县| 上虞市| 邹平县| 大足县| 合江县| 厦门市| 宁津县| 龙江县| 紫云| 贵阳市| SHOW| 墨江| 株洲市| 南雄市| 定远县| 石家庄市| 苗栗市| 封丘县| 阿拉善盟| 温宿县| 宁都县| 高平市| 惠东县| 九台市| 盐城市| 济源市| 大姚县|