terrablocks / aws-sftp-server Goto Github PK
View Code? Open in Web Editor NEWTerraform module to create a managed SFTP server using AWS Transfer service
License: MIT License
Terraform module to create a managed SFTP server using AWS Transfer service
License: MIT License
Hello, I am having some issues when trying to create a PUBLIC SFTP server. I have already tried with VPC option but I would like to have it exposed so anyone with the credentials can access to it.
My code is:
module "sftp" {
source = "github.com/terrablocks/aws-sftp-server.git"
name = local.main_name
sftp_type = "PUBLIC"
protocols = ["SFTP"]
identity_provider_type = "API_GATEWAY"
api_gw_url = module.sftp-idp.invoke_url
invocation_role = aws_iam_role.sftp_iam_role.arn
security_policy_name = "TransferSecurityPolicy-2020-06"
endpoint_details = {
vpc_id = module.vpc.vpc_id
subnet_ids = [module.vpc.public_subnets[0]]
address_allocation_ids = ["eipalloc-044623429a1d3265c"]
security_group_ids = null
}
hosted_zone = data.terraform_remote_state.bootstrap.outputs.route53_zone_name
sftp_sub_domain = var.sftp_conf.dns_subdomain_hostname
sftp_users = var.sftp_conf.sftp_users
tags = { Name = local.main_name }
}
If I set endpoint_details like that, I receive the next error message (allow me to terraform apply):
Error: error creating Transfer Server: InvalidRequestException: EndpointDetails invalid for PUBLIC endpoints
│
│ with module.sftp.aws_transfer_server.this,
│ on .terraform/modules/sftp/main.tf line 97, in resource "aws_transfer_server" "this":
│ 97: resource "aws_transfer_server" "this" {
│
╵
And if I comment it, the message I get is (does not allow me to 'terraform apply'):
│ Error: Invalid function argument
│
│ on .terraform/modules/sftp/main.tf line 104, in resource "aws_transfer_server" "this":
│ 104: for_each = length(var.endpoint_details) == 0 ? [] : [var.endpoint_details]
│ ├────────────────
│ │ var.endpoint_details is null
│
│ Invalid value for "value" parameter: argument must not be null.
I have tried another options changing values and debugging with other resources but I have no clue about what I am missing, so maybe here I can find some help. Thanks a lot.
Terraform v1.0.5
aws-cli/2.4.9
expect no warning when applying terraform
is there a reason to have this? i want to use the module in production but this warning is preventing me as we dont want any warnings for prod. thanks.
╷
│ Warning: Experimental feature "module_variable_optional_attrs" is active
│
│ on .terraform/modules/sftp_server.sftp/requirements.tf line 14, in terraform:
│ 14: experiments = [module_variable_optional_attrs]
│
│ Experimental features are subject to breaking changes in future minor or patch releases, based on feedback.
│
│ If you have feedback on the design of this feature, please open a GitHub issue to discuss it.
╵
No response
- Operating System:
- Terraform Version: v1.2.9
- Provider version:
- Module Version: main
No response
Take the subnet_ids as expected
│ Error: Invalid function argument
│
│ on transfer.tf line 89, in resource "aws_eip" "sftp_vpc":
│ 89: count = var.sftp_type == "VPC" && lookup(var.endpoint_details, "address_allocation_ids", null) == null ? length(lookup(var.endpoint_details, var.subnet_ids[0])) : 0
│ ├────────────────
│ │ var.endpoint_details is object with 4 attributes
│
│ Invalid value for "inputMap" parameter: the given object has no attribute "subnet-XXXXXXXXXXXX".
with this config:
resource "aws_eip" "sftp_vpc" {
count = var.sftp_type == "VPC" && lookup(var.endpoint_details, "address_allocation_ids", null) == null ? length(lookup(var.endpoint_details, var.subnet_ids[0])) : 0
vpc = true
tags = var.tags
}
resource "aws_transfer_server" "vpc" {
count = var.sftp_type != "PUBLIC" ? 1 : 0
endpoint_type = var.sftp_type
protocols = var.protocols
certificate = var.certificate_arn
endpoint_details {
vpc_id = lookup(var.endpoint_details, var.vpc_id, null)
# vpc_endpoint_id = lookup(var.endpoint_details, "vpc_endpoint_id", null)
subnet_ids = lookup(var.endpoint_details, var.subnet_ids[0], null)
security_group_ids = lookup(var.endpoint_details, "security_group_ids", aws_security_group.sftp_vpc..id)
address_allocation_ids = lookup(var.endpoint_details, "address_allocation_ids", aws_eip.sftp_vpc..allocation_id)
}
identity_provider_type = var.identity_provider_type
url = var.api_gw_url
invocation_role = var.invocation_role
directory_id = var.directory_id
function = var.function_arn
logging_role = var.logging_role == null ? join(",", aws_iam_role.logging.*.arn) : var.logging_role
force_destroy = var.force_destroy
security_policy_name = var.security_policy_name
host_key = var.host_key
tags = merge({
Name = local.name
}, var.tags)
}
Note:
Had to also comment out endpoint_details, because it was giving me null errors. Trying to create SFTP server VPC and internet facing.
- Operating System: WSL Ubuntu
- Terraform Version: Terraform v1.0.10
- Provider version:
- Module Version:
No response
I seem to be getting an error when defining a SELF MANAGED, PUBLIC facing SFTP Server.
The error I'm getting is;
│ Error: Invalid function argument
│
│ on .terraform/modules/sftp/main.tf line 100, in resource "aws_security_group" "sftp_vpc":
│ 100: count = var.sftp_type == "VPC" && length(lookup(var.endpoint_details, "security_group_ids", [])) == 0 ? 1 : 0
│ ├────────────────
│ │ var.endpoint_details is null
│
│ Invalid value for "inputMap" parameter: argument must not be null.
It shouldn't be throwing this error as it is not a required field if we aren't using VPC_ENDPOINT? Or am I missing something?
I am using SFTP Server
Thanks
sftp domain
sftp> ls
.... results
access denied
No response
- Operating System: NixOS
- Terraform Version: 1.3.9
- Provider version: 4.40.0
- Module Version: latest master (3399dcd8cd8ae952afc8c8de95d95b88bf37d071)
issue fixed by setting the line 235 to the bucket name: https://github.com/terrablocks/aws-sftp-server/compare/main...shaunsmiley-xevo:aws-sftp-server:minor?expand=1#diff-dc46acf24afd63ef8c556b77c126ccc6e578bc87e3aa09a931f33d9bf2532fbbR235
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.