Skip to content

This terraform module is used to create sftp on AWS for S3.

License

Notifications You must be signed in to change notification settings

test-vaibhav/terraform-aws-sftp

 
 

Repository files navigation

Terraform AWS SFTP

This terraform module is used to create sftp on AWS for S3.

Latest Release tfsec Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Simple Example

PUBLIC

Here is an example of how you can use this module in your inventory structure:

  module "sftp" {
    source         = "clouddrove/sftp/aws"
    version        = "1.3.1"      
    name           = "sftp"
    environment    = "test"
    label_order    = ["environment", "name"]
    enable_sftp    = true
    s3_bucket_name = module.s3_bucket.id
    endpoint_type  = "PUBLIC"
    workflow_details = {
      on_upload = {
        execution_role = "arn:aws:iam::1234567890:role/test-sftp-transfer-role"
        workflow_id    = "w-12345XXXX6da"
      }
    }
  }

VPC

  module "sftp" {
    source                 = "clouddrove/sftp/aws"
    version                = "1.3.1"      
    name                   = "sftp"
    environment            = "test"
    label_order            = ["environment", "name"]
    eip_enabled            = false
    s3_bucket_name         = module.s3_bucket.id
    sftp_users             = var.sftp_users
    subnet_ids             = module.subnets.private_subnet_id
    vpc_id                 = module.vpc.vpc_id
    restricted_home        = true
    vpc_security_group_ids = [module.security_group_sftp.security_group_id]
    workflow_details = {
      on_upload = {
        execution_role = "arn:aws:iam::1234567890:role/test-sftp-transfer-role"
        workflow_id    = "w-12345XXXX6da"
      }
    }
  }

Inputs

Name Description Type Default Required
address_allocation_ids A list of address allocation IDs that are required to attach an Elastic IP address to your SFTP server's endpoint. This property can only be used when endpoint_type is set to VPC. list(string) [] no
attributes Additional attributes (e.g. 1). list(any)
[
"transfer"
]
no
domain Where your files are stored. S3 or EFS string "S3" no
domain_name Domain to use when connecting to the SFTP endpoint string "" no
eip_enabled Whether to provision and attach an Elastic IP to be used as the SFTP endpoint. An EIP will be provisioned per subnet. bool false no
enable_sftp Set to false to prevent the module from creating any resources. bool true no
enable_workflow n/a bool false no
enabled Set to false to prevent the module from creating any resources. bool true no
endpoint_type The type of endpoint that you want your SFTP server connect to. If you connect to a VPC (or VPC_ENDPOINT), your SFTP server isn't accessible over the public internet. If you want to connect your SFTP server via public internet, set PUBLIC. Defaults to PUBLIC string "PUBLIC" no
environment Environment (e.g. prod, dev, staging). string "" no
force_destroy Forces the AWS Transfer Server to be destroyed bool false no
identity_provider_type The mode of authentication enabled for this service. The default value is SERVICE_MANAGED, which allows you to store and access SFTP user credentials within the service. API_GATEWAY. string "SERVICE_MANAGED" no
label_order Label order, e.g. name,application. list(any) [] no
managedby ManagedBy, eg 'CloudDrove'. string "[email protected]" no
name Name (e.g. app or cluster). string "" no
repository Terraform current module repo string "https://github.com/clouddrove/terraform-aws-sftp" no
restricted_home Restricts SFTP users so they only have access to their home directories. bool true no
s3_bucket_name This is the bucket that the SFTP users will use when managing files string n/a yes
security_policy_name Specifies the name of the security policy that is attached to the server. Possible values are TransferSecurityPolicy-2018-11, TransferSecurityPolicy-2020-06, and TransferSecurityPolicy-FIPS-2020-06. Default value is: TransferSecurityPolicy-2018-11. string "TransferSecurityPolicy-2018-11" no
sftp_users List of SFTP usernames and public keys. The keys user_name, public_key are required. The keys s3_bucket_name are optional. any {} no
subnet_ids A list of subnet IDs that are required to host your SFTP server endpoint in your VPC. This property can only be used when endpoint_type is set to VPC. list(string) [] no
vpc_id VPC ID string null no
vpc_security_group_ids A list of security groups IDs that are available to attach to your server's endpoint. If no security groups are specified, the VPC's default security groups are automatically assigned to your endpoint. This property can only be used when endpoint_type is set to VPC. list(string) [] no
workflow_details Workflow details for triggering the execution on file upload.
object({
on_upload = object({
execution_role = string
workflow_id = string
})
})
n/a yes
zone_id Route53 Zone ID to add the CNAME string "" no

Outputs

Name Description
id The Server ID of the Transfer Server (e.g. s-12345678).
tags A mapping of tags to assign to the resource.
transfer_server_endpoint The endpoint of the Transfer Server (e.g. s-12345678.server.transfer.REGION.amazonaws.com).

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

About

This terraform module is used to create sftp on AWS for S3.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 99.6%
  • Makefile 0.4%