Skip to content

miquido/terraform-s3-image-thumbnails-generator

Repository files navigation

terraform-s3-image-thumbnails-generator

Usage

Terraform:

module "s3-image-resizer" {
  source = "git::ssh://git@gitlab.com: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.60

Providers

Name Version
aws ~> 5.60

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_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
  lint                                Lint terraform code

Related Projects

Check out these related projects.

License

License: MIT

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Source: <https://opensource.org/licenses/MIT>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors