tfc-policy-sets-migration

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2019 License: MPL-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Terraform Cloud Policy Sets Migration Utility

This repository contains a useful utility to convert individually-managed policies and policy sets into versioned policy sets. This is achieved by using Terraform Cloud's APIs to mirror all of an organization's policy sets into files on the local disk, and automatically generating the necessary sentinel.hcl configuration file for each policy set.

Imagine you have a couple of policy sets in Terraform Cloud like so:

policy-sets-index

To migrate these policy sets, being by following these steps:

  1. Obtain a Terraform Cloud API token with appropriate permissions to create and manage policy sets, and export it to your local environment like this:

    export TFE_TOKEN=dXXE5KNVu4zJzg.atlasv1.w5vImfBX...
    
  2. Note the organization name in Terraform Cloud you wish to migrate policy sets for.

  3. Invoke the migration utility, passing in the organization name, and the destination directory on your local disk for writing out policies and configurations:

    » ./tfc-policy-sets-migration ryanuber /tmp/policy-sets
    2019/07/08 10:58:40 Mirroring policy set "global" into /tmp/policy-sets/global
    2019/07/08 10:58:41 Mirroring policy set "sunny-day" into /tmp/policy-sets/sunny-day
    
  4. Check out the directory structure created by the script to ensure it matches your policy set configuration in Terraform Cloud:

    » tree /tmp/policy-sets/
    /tmp/policy-sets/
    ├── global
    │   ├── earth-is-round.sentinel
    │   └── sentinel.hcl
    └── sunny-day
        ├── breeze-is-cool.sentinel
        ├── humidity-is-reasonable.sentinel
        ├── sentinel.hcl
        ├── sky-is-clear.sentinel
        └── temperature-is-warm.sentinel
    
    2 directories, 7 files
    

    You should see a directory created for each policy set, a sentinel.hcl configuration file within each policy set directory, and individual .sentinel policy code files for each individual policy.

  5. Now that all of the policy sets have been written to files on the local disk, you can configure new policy sets in Terraform Cloud to either source them from version control, or upload the policy sets individually as tarball (tar.gz) files. Refer to the Sentinel documentation for Terraform Cloud for further guidance.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址