-
-
Save dwolfhub/13889678fe147d158c8c574458739948 to your computer and use it in GitHub Desktop.
Transfer a file to EC2 SSM instance without using S3 (SSM only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm run build-storybook | |
tar --create --gzip --file storybook.tar.gz storybook-static | |
INSTANCE_ID=X | |
# export AWS | |
# Tab 2: | |
# < Start session | |
aws ssm start-session --target $INSTANCE_ID | |
cd ~ | |
# < (On target machine) : | |
sudo nc -l -p 1234 > storybook.tar.gz | |
# Tab 2: On another shell, open a port-forwarding session from your machine to the target machine | |
# export AWS AGAIN | |
# export INSTANCE_ID AGAIN | |
aws ssm start-session --target $INSTANCE_ID --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["1234"],"localPortNumber":["1234"]}' | |
# Tab 3: On yet another shell, cat the source file into the transfer port on localhost over the tunnel | |
nc -w 3 127.0.0.1 1234 < storybook.tar.gz | |
# Step 4: Once the command in step 3 finishes, close all of the other shell sessions. Your file should be on the target now. | |
# Start a new session | |
cd ~/storybook | |
rm -rf ~/storybook/storybook-static | |
tar --gunzip --extract --file ../storybook.tar.gz | |
sudo rm -rf /var/www/storybook/* && sudo cp -R ~/storybook/storybook-static/* /var/www/storybook |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment