Categorygithub.com/S7R4nG3/terraform-resources
modulepackage
0.4.0
Repository: https://github.com/s7r4ng3/terraform-resources.git
Documentation: pkg.go.dev

# README

License: GPL v3 latest build latest release Go Reference

terraform-resources

A package to identify and parse through all resources in a known Terraform plan.

Instead of dicatating a particular configuration language to evaluate your Terraform resources, this package can be leveraged to write your own Golang application to parse the resources in ways that matter to YOU and your organization.

Usage

package main

import (
	"fmt"
    "log"
    "strings"

	tfresources "github.com/S7R4nG3/terraform-resources"
)
func main() {
    // Currently requires that your plan file be exported in json format.
    // This can be accomplished using the following terraform commands:
    //      terraform plan -out=plan.tfplan
    //      terraform show plan.tfplan -json > plan.json
    //
    plan := tfresources.Plan{
        PlanFile: "./deployment/tfplan.json"
    }
    plan.GetResources()
    for _,r := range plan.Resources {
        if strings.Contains(r.Planned.ProviderName, "hashicorp/aws") && r.Planned.Mode != "data" && r.Planned.Type == "aws_s3_bucket" {
            if _, exists := r.Planned.AttributeValues["server_side_encryption_configuration"].([]interface{}); !exists {
                err := fmt.Errorf("S3 bucket -- %s -- does not have encryption enabled!!", r.Name)
                log.Fatal(err)
            }
        }
    }
    fmt.Println("DONE!")
}

Authors

This package was written and maintained by David Streng with the original concept created by Patric Carman.

License

GNU General Public License v3.0 or later

See LICENSE to see the full text.

# Packages

No description provided by the author

# Structs

A Module is a container to hold the parsed contents of a Terraform `modules.json` file.
A Plan initializes a primary configuration container that is used to specify the Terraform planfile as well as the Terraform modules file that are used to link the resources together.
A Resource instantiates a new Terraform resource object that contains all the data Terraform was able to infer about the resource from the provided Terraform plan.