This is the 12th day article of Advent Calender on the 2019 code-server. In What is code-server? on the first day, VSCode is built in using Docker and Docker-Compose in the local environment. I created a development environment. Starting today, we will enter the online version. In the online version, we will launch an Instance on the cloud and place Code-Server there. This gives you access to your development resources from anywhere. Very expensive machine You can use it for a short period of time You will be able to write programs even when you are out using an iPad.
table of contents Local environment 1st day Online environment version 1st day Improve work environment
Online environment, day 2 Create a virtual network
Online environment 3rd day Launch an EC2 instance with Boto3
Online environment 4th day Try running Code-Server in the cloud
Online environment 5th day Launch code-server on Docker
Online environment, day 6 Let's automate
Online environment 7th day Deploy compute on git on EC2
... Online version .. Built with Coompose file
Online .. Try K8S
...
Demon remodeling
I was wondering which environment to use, but decided to use AWS for orthodox. AWS has a service that uses Docker. You can use the Compose file learned in the local version as it is for release. You can use the current method using K8S. But this time, I'd like to start by launching EC2 Instace.
There are several ways to launch an Instance on AWS. --Leadingly operating the GUI console --Use configuration management tools such as CloudFormation and Terraform --Do it from the command line using the AWS CLI --Programmatically using the AWS SDK
I think the standard is to use a configuration management tool. I would like to write in Boto3.
In order to use it from the SDK, you need to get the ACCESS KEY ID and SECRET KEY.
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-chap-configure.html
As described in
1.Sign in to the AWS Management Console and go to the IAM Console (https)://console.aws.amazon.com/iam/) Is opened.
2.In the navigation pane[Users]Choose.
3.Select the user name for which you want to create an access key[Security credentials]Select a tab.
4. [Access keys (access key)]In the section[Create access key (access keyの作成)]Choose.
5.To view the new access key pair[Show]Choose. After closing this dialog box, you will not be able to access the secret access key again. The authentication information is as follows.
Access key ID: AKIAIOSFODNN7EXAMPLE
Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
You can use the Docker created so far as it is.
FROM python:3.8.0-buster
RUN apt-get update
# code-Install wget to get the server
RUN apt-get install -y wget
#Working directory/Make it works. Anywhere is fine
WORKDIR /works
# code-Get the server binary
RUN wget https://github.com/cdr/code-server/releases/download/2.1692-vsc1.39.2/code-server2.1692-vsc1.39.2-linux-x86_64.tar.gz
# code-server/Unzip under works
RUN tar -xzf code-server2.1692-vsc1.39.2-linux-x86_64.tar.gz -C ./ --strip-components 1
WORKDIR /works/app
ENV PYTHONPATH=/works/app
#Install python plugin
RUN /works/code-server --install-extension ms-python.python
RUN /usr/local/bin/python -m pip install -U pylint --user
RUN apt-get install groff -y
#The default is/works/Make it start with app.
CMD [ "/works/code-server", "--allow-http", "--auth", "none", "--port", "8443", "/works/app"]
It's the same !! The environment including docker-compose is set below.
https://github.com/kyorohiro/advent-2019-code-server/tree/master/remote_cs01/for_aws
requirements.txt changes
awscli==1.16.300
boto3==1.10.36
botocore==1.13.36
boto3-type-annotations==0.3.1
rope==0.14.0
$ docker-compose build
$ docker-compose up -d
Try opening http://127.0.0.1:8443/
in your browser.
Open VSCode terminal and install aws cli
$ pip install -r requirements.txt
Set up AWS commands. Add the ACCESS KEY ID and SECRET KEY. If you want to use TOKYO for the region, specify ʻap-northeast-1`.
$ aws configure
AWS Access Key ID [None]: xxxx
AWS Secret Access Key [None]: xxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json
$ aws ec2 describe-instances
Let's create / delete Instance using Boto3.
https://github.com/kyorohiro/advent-2019-code-server/tree/master/remote_cs01
Recommended Posts