Skip to content

Commit

Permalink
New version of terraform (0.9.11), terragrunt (0.13.24.01), gotemplat…
Browse files Browse the repository at this point in the history
…e (1.01), quantum (0.2)

Change the configuration mechanism from tags on security group to parameters store
No longer check update on versioned image
Add tflint to the default image
  • Loading branch information
jocgir committed Jul 7, 2017
1 parent c75d761 commit e6513ac
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
FROM alpine:latest

ARG TERRAFORM_VERSION=0.9.8
ARG TERRAFORM_QUANTUM=0.1
ARG TERRAGRUNT_VERSION=0.12.18.04
ARG GOTEMPLATE_VERSION=1.0
ARG TERRAFORM_VERSION=0.9.11
ARG TERRAFORM_QUANTUM=0.2
ARG TERRAGRUNT_VERSION=0.12.24.01
ARG GOTEMPLATE_VERSION=1.01
ARG TFLINT_VERSION=0.3.6

LABEL vendor="Coveo"
LABEL maintainer "jgiroux@coveo.com"

RUN apk update && apk add openssl ca-certificates

RUN wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -O terraform.zip && unzip terraform.zip && mv terraform /usr/local/bin && rm terraform.zip
RUN wget https://github.com/coveo/terraform-provider-quantum/releases/download/v${TERRAFORM_QUANTUM}/terraform-provider-quantum_linux -O /usr/local/bin/terraform-provider-quantum && chmod +x /usr/local/bin/terraform-provider-quantum
RUN wget https://github.com/coveo/terraform-provider-quantum/releases/download/v${TERRAFORM_QUANTUM}/terraform-provider-quantum_linux_x64 -O /usr/local/bin/terraform-provider-quantum && chmod +x /usr/local/bin/terraform-provider-quantum
RUN wget https://github.com/coveo/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 -O /usr/bin/terragrunt && chmod +x /usr/bin/terragrunt
RUN wget https://github.com/coveo/gotemplate/releases/download/v${GOTEMPLATE_VERSION}/gotemplate_linux -O /usr/bin/gotemplate && chmod +x /usr/bin/gotemplate
RUN wget https://github.com/wata727/tflint/releases/download/v${TFLINT_VERSION}/tflint_linux_amd64.zip -O tflint.zip && unzip tflint.zip && mv tflint /usr/local/bin && rm tflint.zip

RUN apk add bash zsh fish
RUN apk add py2-pip python3
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.Base
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM alpine:latest

ARG TERRAFORM_VERSION=0.9.8
ARG TERRAGRUNT_VERSION=0.12.18.04
ARG GOTEMPLATE_VERSION=1.0
ARG TERRAFORM_VERSION=0.9.11
ARG TERRAGRUNT_VERSION=0.12.24.01
ARG GOTEMPLATE_VERSION=1.01

LABEL vendor="Coveo"
LABEL maintainer "jgiroux@coveo.com"
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile.Full
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM ubuntu:latest

ARG TERRAFORM_VERSION=0.9.8
ARG TERRAFORM_QUANTUM=0.1
ARG TERRAGRUNT_VERSION=0.12.18.04
ARG GOTEMPLATE_VERSION=1.0
ARG TERRAFORM_VERSION=0.9.11
ARG TERRAFORM_QUANTUM=0.2
ARG TERRAGRUNT_VERSION=0.12.24.01
ARG GOTEMPLATE_VERSION=1.01
ARG TFLINT_VERSION=0.3.6

ARG DEBIAN_FRONTEND=noninteractive

LABEL vendor="Coveo"
Expand Down Expand Up @@ -45,9 +47,10 @@ RUN powershell -c Install-Package AWSPowerShell.NetCore -Force > /dev/null

# Installiing terraform and terragrunt
RUN curl -sL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && unzip terraform.zip && mv terraform /usr/local/bin && rm terraform.zip
RUN curl -sL https://github.com/coveo/terraform-provider-quantum/releases/download/v${TERRAFORM_QUANTUM}/terraform-provider-quantum_linux -o /usr/local/bin/terraform-provider-quantum && chmod +x /usr/local/bin/terraform-provider-quantum
RUN curl -sL https://github.com/coveo/terraform-provider-quantum/releases/download/v${TERRAFORM_QUANTUM}/terraform-provider-quantum_linux_x64 -o /usr/local/bin/terraform-provider-quantum && chmod +x /usr/local/bin/terraform-provider-quantum
RUN curl -sL https://github.com/coveo/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 -o /usr/bin/terragrunt && chmod +x /usr/bin/terragrunt
RUN curl -sL https://github.com/coveo/gotemplate/releases/download/v${GOTEMPLATE_VERSION}/gotemplate_linux -o /usr/bin/gotemplate && chmod +x /usr/bin/gotemplate
RUN curl -sL https://github.com/wata727/tflint/releases/download/v${TFLINT_VERSION}/tflint_linux_amd64.zip -o tflint.zip && unzip tflint.zip && mv tflint /usr/local/bin && rm tflint.zip

# Install JQ
RUN apt-get -y install jq
Expand Down
10 changes: 5 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/gruntwork-io/terragrunt/util"
"time"

aws "github.com/gruntwork-io/terragrunt/aws_helper"
)

type tgfConfig struct {
Expand All @@ -18,15 +19,14 @@ func getDefaultValues() tgfConfig {
LogLevel: "notice",
}

tags, _ := util.GetSecurityGroupTags("terragrunt-default")
if image, ok := tags["tgf_docker_image"]; ok {
if image, err := aws.GetSSMParameter("/default/tgf/docker-image", ""); err == nil {
config.Image = image
}
if refresh, ok := tags["tgf_docker_refresh"]; ok {
if refresh, err := aws.GetSSMParameter("/default/tgf/docker-refresh", ""); err == nil {
duration := Must(time.ParseDuration(refresh)).(time.Duration)
config.Refresh = duration
}
if logLevel, ok := tags["tgf_logging_level"]; ok {
if logLevel, err := aws.GetSSMParameter("/default/tgf/logging-level", ""); err == nil {
config.LogLevel = logLevel
}

Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package main

import (
"fmt"
"gopkg.in/alecthomas/kingpin.v2"
"os"
"path/filepath"
"strings"

"gopkg.in/alecthomas/kingpin.v2"
)

func main() {
Expand Down Expand Up @@ -41,9 +43,11 @@ func main() {
config.Image = strings.Join([]string{split[0], *tag}, ":")
}

if lastRefresh(config.Image) > config.Refresh || !checkImage(config.Image) || *refresh {
if !isVersionedImage(config.Image) && lastRefresh(config.Image) > config.Refresh || !checkImage(config.Image) || *refresh {
refreshImage(config.Image)
}

os.Setenv("TERRAGRUNT_CACHE", filepath.Join("/local", os.TempDir(), "tgf-cache"))

callDocker(config.Image, config.LogLevel, *entryPoint, unmanaged...)
}
12 changes: 11 additions & 1 deletion touch.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package main

import (
"github.com/gruntwork-io/terragrunt/util"
"os"
"os/user"
"path/filepath"
"regexp"
"time"

"github.com/gruntwork-io/terragrunt/util"
)

func getTouchFilename(image string) string {
Expand Down Expand Up @@ -42,3 +44,11 @@ func touchImageRefresh(image string) {
func lastRefresh(image string) time.Duration {
return time.Since(getLastRefresh(image))
}

// By default, versionned images do not need to be refreshed since they should never
// been overwritten with a different version without being tagged with a new version.
func isVersionedImage(image string) bool {
return versionRegex.MatchString(image)
}

var versionRegex = regexp.MustCompile(`[vV]?\d+\.\d+`)

0 comments on commit e6513ac

Please sign in to comment.