- 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
推薦閱讀
- Unreal Engine:Game Development from A to Z
- 輕松學C語言
- 圖形圖像處理(Photoshop)
- MicroPython Projects
- 影視后期編輯與合成
- The Python Workshop
- 簡明學中文版Photoshop
- 寒江獨釣:Windows內核安全編程
- 工業(yè)機器人入門實用教程
- 30天學通Java Web項目案例開發(fā)
- Access 2007數(shù)據(jù)庫入門與實例應用金典
- 數(shù)據(jù)結構與實訓
- Arduino創(chuàng)意機器人入門:基于Mind+
- 數(shù)據(jù)結構與算法(C++語言版)
- 歐姆龍CP1H型PLC編程與應用