- 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
推薦閱讀
- Hands-On Deep Learning with Apache Spark
- 繪制進程圖:可視化D++語言(第1冊)
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- 網(wǎng)絡(luò)組建與互聯(lián)
- 系統(tǒng)安裝與重裝
- JavaScript典型應(yīng)用與最佳實踐
- 變頻器、軟啟動器及PLC實用技術(shù)260問
- Android游戲開發(fā)案例與關(guān)鍵技術(shù)
- 基于單片機的嵌入式工程開發(fā)詳解
- Learn CloudFormation
- 大數(shù)據(jù)技術(shù)基礎(chǔ):基于Hadoop與Spark
- WOW!Photoshop CS6完全自學(xué)寶典
- 貫通Java Web輕量級應(yīng)用開發(fā)
- 信息系統(tǒng)安全保障評估
- 大話數(shù)據(jù)科學(xué):大數(shù)據(jù)與機器學(xué)習(xí)實戰(zhàn)(基于R語言)