- Ansible 2 Cloud Automation Cookbook
- Aditya Patawari Vikas Aggarwal
- 109字
- 2021-06-24 18:43:37
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
推薦閱讀
- 零起步輕松學單片機技術(shù)(第2版)
- Practical Data Wrangling
- 輕松學Java
- Hands-On Neural Networks with Keras
- 快學Flash動畫百例
- Pig Design Patterns
- 系統(tǒng)安裝與重裝
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- 中國戰(zhàn)略性新興產(chǎn)業(yè)研究與發(fā)展·智能制造
- 面向?qū)ο蟪绦蛟O計綜合實踐
- 精通LabVIEW程序設計
- 嵌入式GUI開發(fā)設計
- ASP.NET 2.0 Web開發(fā)入門指南
- 寒江獨釣:Windows內(nèi)核安全編程
- Apache Spark Quick Start Guide