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

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
主站蜘蛛池模板: 耒阳市| 太湖县| 台东县| 望都县| 丁青县| 清水河县| 丰宁| 拜泉县| 婺源县| 易门县| 海门市| 石泉县| 阿拉善盟| 广德县| 渝中区| 济阳县| 巩留县| 平度市| 桂阳县| 龙里县| 五峰| 高阳县| 阜宁县| 利津县| 铅山县| 三亚市| 高陵县| 台东市| 福贡县| 银川市| 正宁县| 比如县| 临清市| 江都市| 密云县| 南华县| 惠州市| 波密县| 福海县| 西充县| 民县|