Book Image

Salt Cookbook

By : Anirban Saha
Book Image

Salt Cookbook

By: Anirban Saha

Overview of this book

Table of Contents (18 chapters)
Salt Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Implementing security groups


Before compute resources can be configured, it is extremely important to configure the proper security measures to be taken to avoid unwanted access. In this recipe, we will learn about how to configure security groups using Salt in AWS.

How to do it...

  1. Configure a new state called aws in the production environment. Create /opt/ salt-cookbook/production/aws/secgroup.sls to have the following entries:

    cookbooksecgroup:
        boto_secgroup.present:
            - description: Cookbook security group
            - rules:
                - ip_protocol: tcp
                  from_port: 80
                  to_port: 80
                  cidr_ip:
                    - 172.31.0.0/20
                    - 172.31.16.0/20
            - vpc_id: vpc-45f53420
            - region: us-west-2
            - keyid: <access-key>
            - key: '<secret-key>'
  2. Apply the state to the Salt master by running the following command:

    [root@salt-master ~]# salt 'salt-master' state.sls aws.secgroup saltenv=production
    salt-master...