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

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
主站蜘蛛池模板: 鄂托克旗| 武功县| 晴隆县| 绥棱县| 临沭县| 舟曲县| 东宁县| 五台县| 太仓市| 新蔡县| 临邑县| 新丰县| 福州市| 偃师市| 肥城市| 通许县| 吉安县| 平度市| 台南市| 新乡市| 新密市| 泰安市| 石泉县| 华阴市| 洪雅县| 曲麻莱县| 白山市| 宜都市| 北辰区| 高密市| 金湖县| 新龙县| 疏附县| 托克托县| 开阳县| 永寿县| 岳池县| 双桥区| 游戏| 磐石市| 饶河县|