Skip to content

miquido/terraform-s3-image-thumbnails-generator

Repository files navigation

Miquido

terraform-s3-image-thumbnails-generator


Terraform Module

GitLab Repository: https://gitlab.com/miquido/terraform/terraform-s3-image-thumbnails-generator

Usage

Terraform:

module "s3-image-resizer" {
  source = "git::ssh://[email protected]:miquido/terraform/terraform-s3-image-thumbnails-generator.git?ref=master"

  namespace        = "${var.project}"
  stage            = "${var.environment}"
  thumbnail_widths = [1200,800,600,400,200]

  namespace                 = var.project
  stage                     = var.environment
  name                      = "image-resizer"
  thumbnail_widths          = [1200, 800, 600, 400, 200]
  user_enabled              = false
  s3_region                 = var.aws_region
  s3_acl                    = "private"
  bucket_enabled            = true
  bucket_versioning_enabled = true
  log_retention             = 7
  tags                      = var.tags
}

Building lambda

Warning: This process requires x86 compatible machine (does not work currently on ARM).

  1. Edit files in src/ directory
  2. Run script:
make lint
make build/lambda-zip
make build/lambda-layer-zip

Requirements

Name Version
terraform >= 1.0
aws ~> 5.16

Providers

Name Version
aws ~> 5.16

Modules

Name Source Version
label cloudposse/label/terraform 0.8.0
s3-bucket-api-images cloudposse/s3-bucket/aws 3.0.0

Resources

Name Type
aws_cloudwatch_log_group.default resource
aws_iam_role.default resource
aws_iam_role_policy.default resource
aws_lambda_event_source_mapping.new_object resource
aws_lambda_function.default resource
aws_lambda_layer_version.lambda_layer resource
aws_lambda_permission.s3_notification resource
aws_s3_bucket_notification.new_object resource
aws_sns_topic.image_thumbnails_generated resource
aws_sqs_queue.new_object resource
aws_sqs_queue.new_object_deadletter resource
aws_sqs_queue_policy.s3_send_message_2_sqs resource
aws_caller_identity.current data source
aws_iam_policy_document.assume_role data source
aws_iam_policy_document.default data source
aws_region.current data source

Inputs

Name Description Type Default Required
attributes Additional attributes (e.g. 1) list(string) [] no
bucket_enabled Whether to create S3 Bucket. If value is false, the argument bucket_id is required. bool true no
bucket_id The ID of S3 Bucket to use. If provided module won't create S3 bucket itself. Required if bucket_enabled=false. string "" no
bucket_versioning_enabled Whether to turn bucket versioning on bool true no
delimiter Delimiter to be used between namespace, stage, name and attributes string "-" no
log_retention Specifies the number of days you want to retain log events in the specified log group number 7 no
name Solution name, e.g. 'app' or 'cluster' string "s3-image-resizer" no
namespace Namespace, which could be your organization name, e.g. 'eg' or 'cp' string n/a yes
s3_acl The canned ACL to apply. Defaults to private. See: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl string "private" no
s3_region The AWS Region where S3 Bucket is created or should be created. By default it is the region of current AWS provider. string "" no
stage Stage, e.g. 'prod', 'staging', 'dev', or 'test' string n/a yes
tags Additional tags (e.g. map('BusinessUnit','XYZ') map(string) {} no
thumbnail_widths Target widths of generated thumbnails list(string) n/a yes
user_enabled Whether to create IAM User with RW permissions to created s3 bucket. Ignored when bucket_enabled=false. bool true no

Outputs

Name Description
access_key_id The access key ID
bucket_id Bucket Name (aka ID)
secret_access_key The secret access key. This will be written to the state file in plain-text
sns_topic_arn SNS topic for newly uploaded files

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen

Developing

  1. Make changes in terraform files

  2. Regenerate documentation

    bash <(git archive [email protected]:miquido/terraform/terraform-readme-update.git master update.sh | tar -xO)
  3. Run lint

    make lint
    

Copyright

Copyright © 2017-2023 Miquido

Contributors

Paweł Jędruch
Paweł Jędruch
Konrad Obal
Konrad Obal