Hi, i recently started studying for aws developer associate certification, i am developing a small flask application for learning on an ubuntu ec2 instance, however I’m finding using the nano editor very cumbersome, i am thinking of writing the code on local machine then uploading to s3 then downloading code on ec2 from s3, is there any other way to do this efficiently and faster?
Thanks for reading!
Many roads to rome but what I do is develop on local machines, track all changes with Git and simply pull the git repository on a staging server first and then onto the production server if no bugs are found.
After most updates I delete the EC2 staging instance and create a new one from a recent snapshot if a new update is ready.
You could also install a Desktop Environment
and the x2go server side component on the ubuntu server both are just 1 or 2 apt commands
Then on your client side install the x2go client.. again just 2 cmds.
Start the x2go client, create a new session config w IP of the EC2 ubuntu, ID the DE you put on the EC2 instance.
The execute that “session” in the x2go client
Within a couple of seconds you will have a desktop from the server, be able to cut&paste, print, share files, have audio etc from the remote desktop to you locally.
Just remember on the EC2 ubuntu to configure /etc/ssh/sshd_config for whether you are using login ID/Password or ssh keys etc to match what you configured into the x2go “session” config
You can checkout AWS Codepipeline.
Rough steps would be
- You can use git to track your changes locally.
- use AWS CodeCommit as your remote git repo.
- Use AWS Codebuild to build your code
- Use AWS CodeDeploy to deploy your code to ec2 instance.
You will install code deploy agent on your EC2 instance. CodePipeline can be used to connect CodeCommit to Codebuilt, to CodeDeploy.
So whenever you make a commit, codePipeline gets to work. It copies over your code and builds using CodeBuild. The intermediate artifacts are stored in S3. Next, codeDeploy will pull these artifact and notify the codeDeploy Agent in your EC2 instance. Now codeDeploy agent can pull in your changes, and then run the installation script.
I feel this is a good setup, if you have some tests you can also add a stage to run your tests before deploying. This comes very much near to having a stable workflow.
You can use AWS console GUI to setup pipelines and stuff or use cloudformation scripts.
If I’m doing development on a remote machine (typically development-type environment), then there are a few options I’ll pick from for my use case. Each one allows me to use my IDE locally, but there are trade-offs.
For projects that will take a while, I’ll set up PHPStorm/PyCharm to autodeploy via SFTP on file save (see the deployment section). This keeps the files on the server in-sync as I edit them locally. Takes a some time to configure.
For larger projects that I need to do quick fixes on, I’ll typically use rsync on the command line to copy files up when I’m ready to test on dev. Something like rsync -a folder/to/sync user@server:/path/to/remote\_folder. It’s roughly the same syntax as scp, but it only copies changed files. Fast to set up, fast to copy, but you have to remember to copy changes up to test.
For really small projects (<20 files), sometimes I’ll use a SSH mount (sshfs). This makes the remote files appear as local ones. This is simple since there’s only one set of files, but if the project gets too large, your IDE (and git) will become incredibly slow.
For higher environments (UAT / staging / prod-like), then I’ll have something staged in git and pull code from there. If there’s a hotfix I need to test, I’ll just use vim on the server.
Git of course. If we want something more advance than use AWS Code Deploy, it takes like 15 minutes to set the basic scenario and comes with loads and loads and loads of stuff out-of-the-box like automatic green-blue.