Search code examples
cloudsalt-project

Saltstack boto_vpc state execution


I have the following state in SaltStack that i'm trying to execute in order to create a VPC in AWS.

vpc_exists:
  boto_vpc.present:
    - name: saltstack_test_vpc
    - cidr_block: 10.0.0.0/16
    - dns_hostnames: True
    - region: us-east-1
    - keyid: SECRET_KEY_ID
    - key: SECRET_KEY

Although the documentation in https://docs.saltstack.com/en/latest/ref/states/all/salt.states.boto_vpc.html#manage-vpcs says how to create the state, it does not say how to execute it. What i have not been able to find out, is how to execute this state. Obviously, here i don't have a target system as i have when pushing configuration to a server by doing: salt -v 'TARGET_SERVER' state.highstate

So my question is how can one execute this state or any other boto_vpc states ?

Thank you in advance !


Solution

    1. Install salt-minion into your salt master as well. E.g., let say your saltmaster hostname is my-salt, you should see a key appear using sudo salt-key -L

    2. Accept the key, e.g. sudo salt-key -a my-salt

    3. Now in your top.sls, create entry that target your own salt-minion my-salt.

    4. run highstate against your own minion sudo salt "my-salt" state.highstate

    you top.sls should looks something like following. And your above code are named as createvpc.sls

    base:
      "my-salt":
        createvpc