Skip to content

A terraform provider to create to create a zip file from different kind of source.

License

Notifications You must be signed in to change notification settings

volkc-basf/terraform-provider-zipper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform-provider-zipper Build Status License: MIT

A terraform provider to create to create a zip file from different kind of source, this sources can be:

It uses zipper under the hood.

Installations

Requirements: You need, of course, terraform (>=0.12) which is available here: https://www.terraform.io/downloads.html

Automatic

To install a specific version, set PROVIDER_CLOUDFOUNDRY_VERSION before executing the following command

$ export PROVIDER_ZIPPER_VERSION="v0.12.0"

via curl

$ bash -c "$(curl -fsSL https://raw.github.com/ArthurHlt/terraform-provider-zipper/master/bin/install.sh)"

via wget

$ bash -c "$(wget https://raw.github.com/ArthurHlt/terraform-provider-zipper/master/bin/install.sh -O -)"

Manually

  1. Get the build for your system in releases: https://github.com/ArthurHlt/terraform-provider-zipper/releases/latest
  2. Create a providers directory inside terraform user folder: mkdir -p ~/.terraform.d/providers
  3. Move the provider previously downloaded in this folder: mv /path/to/download/directory/terraform-provider-zipper ~/.terraform.d/providers
  4. Ensure provider is executable: chmod +x ~/.terraform.d/providers/terraform-provider-zipper
  5. add providers path to your .terraformrc:
cat <<EOF > ~/.terraformrc
providers {
    zipper = "/full/path/to/.terraform.d/providers/terraform-provider-zipper"
}
EOF
  1. you can now performs any terraform action on zipper resources

Usage

Simple example to retrieve a git repository and use it on AWS Lambda function:

provider "zipper" {
  skip_ssl_validation = false
}

resource "zipper_file" "fixture" {
  source = "https://github.com/ArthurHlt/go-lambda-ping.git"
  output_path = "path/to/lambda/function.zip"
}

resource "aws_iam_role" "lambda_exec_role" {
  name = "lambda_exec_role"
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_lambda_function" "demo_lambda" {
  function_name = "demo_lambda"
  handler = "main"
  runtime = "go1.x"
  filename = "${zipper_file.fixture.output_path}"
  source_code_hash = "${zipper_file.fixture.output_sha}"
  role = "${aws_iam_role.lambda_exec_role.arn}"
}

Resource zipper_file

Zip file from different kind of source as resource by using zipper. Using as resource permit to not download when not necessary.

Example Usage

Basic usage

resource "zipper_file" "fixture" {
  type = "git"
  source = "https://github.com/ArthurHlt/go-lambda-ping.git"
  output_path = "path/to/lambda/function.zip"
  not_when_nonexists = false
}

Argument Reference

The following arguments are supported:

  • source - (Required) Target source for zipper written in uri style (see zipper doc for more information).
  • output_path - (Required) The output of the archive file.
  • type - (Optional) Source type to use to create zip, e.g.: http, local or git. (if omitted type will be auto-detected)
  • not_when_nonexists - (Optional) Set to true to not create zip when not exists at output_path if sources files didn't change. (to earn time if not necessary)

Attributes Reference

The following attributes are exported:

  • id - Id is actually equivalent to output_sha.
  • output_sha - SHA1 checksum made by zipper.
  • output_size - Size of the zip file.

Datasource zipper_file

Equivalent to resource but less smart to know when to download or not source (less restrictive than a resource).

About

A terraform provider to create to create a zip file from different kind of source.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 79.4%
  • Shell 20.6%