Changing the Default Cloud Connection
Overview
This article covers how to set a custom Cloud Connection on launch, instead of the default S3 bucket (which starts with sftpgw-
).
This process involves editing the SFTP Gateway CloudFormation template prior to deployment.
Note: When configuring your cloudformation stack, make sure to select open
for the BucketAccess parameter if you are using instance identity.
Editing the Template
Under UserData, you can run commands during deployment. You will be appending lines to the application.properties
file, which in turn writes changes to the database.
The UserData section looks like this:
UserData:
Fn::Base64: !Sub |
#cloud-config
repo_update: true
repo_upgrade: all
write_files:
- content : |
#!/bin/bash
export CLOUD_PROVIDER=aws
export ARCHITECTURE=Single
export LOG_GROUP_NAME=${LogGroup}
path: /opt/sftpgw/launch_config.env
runcmd:
- /opt/aws/bin/cfn-init --stack ${AWS::StackName} --resource SFTPGatewayInstance --region ${AWS::Region}
- /opt/aws/bin/cfn-signal -e 0 --stack ${AWS::StackName} --resource SFTPGatewayInstance --region ${AWS::Region}
Modify it so that it looks like this:
UserData:
Fn::Base64: !Sub |
#cloud-config
repo_update: true
repo_upgrade: all
write_files:
- content : |
#!/bin/bash
export CLOUD_PROVIDER=aws
export ARCHITECTURE=Single
export LOG_GROUP_NAME=${LogGroup}
path: /opt/sftpgw/launch_config.env
- content : |
features.first-connection.cloud-provider=aws
features.first-connection.name=default
features.first-connection.base-prefix=my-custom-bucket-name
features.first-connection.notes="Initialized from configuration properties."
features.first-connection.region=${AWS::Region}
features.first-connection.use-instance-credentials=true
append: true
path: /opt/sftpgw/application.properties
runcmd:
- /opt/aws/bin/cfn-init --stack ${AWS::StackName} --resource SFTPGatewayInstance --region ${AWS::Region}
- sudo service sftpgw-admin-api restart
- /opt/aws/bin/cfn-signal -e 0 --stack ${AWS::StackName} --resource SFTPGatewayInstance --region ${AWS::Region}
You are making two changes:
First, you are appending the following lines to application.properties
:
features.first-connection.cloud-provider=aws
features.first-connection.name=default
features.first-connection.base-prefix=my-custom-bucket-name
features.first-connection.notes="Initialized from configuration properties."
features.first-connection.region=us-east-1
features.first-connection.use-instance-credentials=true
These properties define the default Cloud Connection.
Note: Make sure you change the base-prefix
to use a real S3 bucket name. Also, update the region
.
Second, you are restarting the Java service to apply these changes:
sudo service sftpgw-admin-api restart