Skip to content

Instantly share code, notes, and snippets.

@tomharrisonjr
tomharrisonjr / enabled.tf
Created December 7, 2021 06:26
Use enabled instead of count
data "aws_iam_policy_document" "data" {
enabled = terraform.workspace == "production"
statement {
actions = [
"s3:GetBucketLocation",
"s3:ListBucket",
]
resources = [
@tomharrisonjr
tomharrisonjr / count_as_enabled.tf
Created December 7, 2021 05:21
Count as enabled
data "aws_iam_policy_document" "data" {
count = terraform.workspace == "production" ? 1 : 0
statement {
actions = [
"s3:GetBucketLocation",
"s3:ListBucket",
]
resources = [
@tomharrisonjr
tomharrisonjr / count.tf
Created December 7, 2021 05:14
Terraform count as a number
resource "aws_instance" "server" {
count = 4 # create four similar EC2 instances
ami = "ami-a1b2c3d4"
instance_type = "t2.micro"
tags = {
Name = "Server ${count.index}"
}
}
@tomharrisonjr
tomharrisonjr / datalookup.tf
Created December 1, 2021 04:07
terraform_examples
data "aws_s3_bucket" "widget_data" {
name = "acmecorp_widget_data"
}
@tomharrisonjr
tomharrisonjr / google_api.rb
Created August 30, 2012 22:35
Example Ruby on Rails library for Google API, Google Analytics Network (GAN), events/list API, as well as others using Installed Applications approach
module GoogleApi
# Inspired by http://www.ericnagel.com/how-to-tips/google-affiliate-network-api.html
require 'rest-client'
require 'active_support'
# Google Affiliate Network
class GAN
# These values obtained from https://code.google.com/apis/console, creating a client ID for Installed Applications
CLIENT_ID = '<your-value>.apps.googleusercontent.com'
CLIENT_SECRET = '<your-value>'