Skip to content

Instantly share code, notes, and snippets.

View rberlind's full-sized avatar

Roger Berlind rberlind

View GitHub Profile
@rberlind
rberlind / restrict-acm-certificate-domains-2.sentinel
Created April 3, 2020 16:09
restrict-acm-certificate-domains-2.sentinel
# This policy uses the tfstate import to restrict ACM certificates
# to have domains that are sub-domains of hashidemos.io
# Import the v2 tfstate import, but use the alias "tfstate"
import "tfstate/v2" as tfstate
# Import common-functions/tfstate-functions.sentinel with alias "state"
import "tfstate-functions" as state
# Get all AWS ACM certs
@rberlind
rberlind / mock-tfconfig-fake-modules.sentinel
Last active March 13, 2019 18:53
TFE Sentinel tfconfig mock with two fake modules
_root = {
"data": {},
"modules": {
"Carol": {
"config": {
"name": "Carol",
},
"source": "github.com/rberlind/terraform-local-fake",
"version": "1.0.1",
},
@rberlind
rberlind / mock-tfconfig-azure-modules.sentinel
Last active March 13, 2019 18:54
TFE Sentinel tfconfig mock with Azure modules
_root = {
"data": {},
"modules": {
"network": {
"config": {
"allow_ssh_traffic": "1",
"location": "${var.location}",
"resource_group_name": "${var.windows_dns_prefix}-rc",
},
"source": "Azure/network/azurerm",
@rberlind
rberlind / main.tf
Created April 12, 2018 21:20
Terraform config to test assume role from EC2 Role
provider "aws" {
assume_role {
role_arn = "arn:aws:iam::128997349609:role/terraform-role"
session_name = "terraform"
}
}
resource "aws_instance" "web" {
ami = "ami-2e1ef954"
instance_type = "t2.micro"
Terraform v0.10.8
Configuring remote state backend...
Initializing Terraform configuration...
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.vault_generic_secret.gcp_credentials: Refreshing state...
google_container_cluster.k8sexample: Refreshing state... (ID: k8sexample-cluster)
@rberlind
rberlind / Terraform-Vault-K8s
Created November 17, 2017 23:55
Trace logging from Terraform Crash
Terraform v0.10.8
Configuring remote state backend...
Initializing Terraform configuration...
2017/11/17 23:47:11 [INFO] Terraform version: 0.10.8 44110772d9ffd0ec3589943c6d4c93c24a5fff06
2017/11/17 23:47:11 [INFO] Go runtime version: go1.9
2017/11/17 23:47:11 [INFO] CLI args: []string{"/usr/local/bin/terraform", "plan", "-out", "/terraform/terraform.tfplan", "-detailed-exitcode", "-module-depth=-1", "-parallelism=10", "-destroy"}
2017/11/17 23:47:11 [DEBUG] Attempting to open CLI config file: /home/terraform/.terraformrc
2017/11/17 23:47:11 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/11/17 23:47:11 [DEBUG] CLI config is &main.Config{Providers:map[string]string{}, Provisioners:map[string]string{}, DisableCheckpoint:false, DisableCheckpointSignature:false, PluginCacheDir:"", Credentials:map[string]map[string]interface {}(nil), CredentialsHelpers:map[string]*main.ConfigCredentialsHelper(nil)}