Giter Site home page Giter Site logo

aws-samples / ftp-with-password-authentication-cdk-sample Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 1.0 1.12 MB

Transfer Family FTP/SFTP server with password authentication sample with TypeScript CDK

License: MIT No Attribution

JavaScript 2.32% Python 50.31% TypeScript 47.37%
ftp sftp cdk

ftp-with-password-authentication-cdk-sample's Introduction

Transfer Family FTP server with password authentication CDK sample

Build

This sample shows how to define Transfer Family FTP/SFTP server with password authentication by AWS CDK.

It includes CDK constructs that follows the below architecture, and a CDK stack to show how to use the constructs.

architecture

You can read this article for futher detail of the architecture: Enable password authentication for AWS Transfer Family using AWS Secrets Manager (updated)

Code sample

In this sample, you can define FTP server with password authentication by the following code:

// an AWS Transfer SFTP server
const ftp = new PasswordAuthenticatedFtp(this, `Ftp`, {
    vpc,
    protocol: "SFTP",
});

// Create an FTP user with randomly generated password
new FtpUser(this, `User1`, {
    transferServerId: ftp.server.attrServerId,
    accessibleBucket: bucket,
    homeDirectory: "home",
});

// You can also specify password explicitly
new FtpUser(this, `User2`, {
    transferServerId: ftp.server.attrServerId,
    accessibleBucket: bucket,
    homeDirectory: "home",
    password: "passw0rd",
});

The actual constructs are located in lib/ftp directory. You can copy these files into your project and freely modify them as your own requirements.

Deploy

Before deploying this sample, you must install AWS Cloud Development Kit prerequisites. Please refer to this document for the detailed instruction. Please make sure you've successfully completed cdk bootstrap step.

After that, clone this repository and go to the root directory.

You must first install Node.js dependencies for CDK code by the following commands:

npm ci

Now you can deploy this sample stack (FtpSampleStack) by the following command:

npx cdk deploy --require-approval never

Initial deployment usually takes about 10 minutes.

After a successful deployment, you can check the name of the S3 bucket and EC2 instance id for the testing purpose in the stack output.

stack output

Usage

After the deployment, let's check if the sample is successfuly deployed by actually connecting to your SFTP server.

First check the IP address of your SFTP server. You can find it in AWS Transfer Family Management console.

Then connect to the EC2 instance via SSM Session Manager. It will work as a SFTP client for testing. To connect your EC2 instancne, please check the following document: Connect to your Linux instance using Session Manager.

In the EC2 ssh session, to connect your SFTP server, run the command below and enter the password.

sftp [username]@[IP address of your SFTP server]

For this sample, you can use the below login credentials.

username password
user1 Randomly generated; see Secrets Manager console for its value
user2 password

Now you should be able to successfully login to the SFTP server. Let's test some SFTP commands to transfer files.

You can find the actual transferred files in the S3 bucket. Check it in S3 management console.

Clean up

To avoid incurring future charges, clean up the resources you created.

You can remove all the AWS resources deployed by this sample running the following command:

npx cdk destroy --force

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

ftp-with-password-authentication-cdk-sample's People

Contributors

amazon-auto avatar dependabot[bot] avatar tmokmss avatar yukinobu-mine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

craigspaz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.