# 創建 Elastic Beanstalk 應用程序、環境、應用程序版本 [TOC] ###### tags: `aws` `eb` --- 先安裝… - EB CLI ## 創建 application ```shell % eb init \ -k {keyname} \ -p {platform-version} \ --profile {profile} \ --region {region} \ {application-name} ``` :::info 問:為何不使用 [`aws elasticbeanstalk create-application`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticbeanstalk/create-application.html)⁉️ 答:因為 [`aws elasticbeanstalk create-application`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticbeanstalk/create-application.html) 無法指定 keypair、region 等配置。 ::: ## 創建 environment ```shell % eb create \ -c {subdomain-name} \ --elb-type {type} \ --envvars {name1=value1,name2=value2} \ -i \ -im {number-of-instances} \ -ix {number-of-instances} \ -p {platform-version} \ -pr \ -r {region} \ --scale {number-of-instances} \ --vpc \ --vpc.ec2subnets {subnet1,subnet2} \ --vpc.elbpublic \ --vpc.elbsubnets {subnet1,subnet2} \ --vpc.id {id} \ --vpc.publicip \ --vpc.securitygroups {securitygroup1,securitygroup2} \ --profile {profile} \ --region {region} \ {environment-name} ``` :::info 問:為何不使用 [`aws elasticbeanstalk create-environment`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticbeanstalk/create-environment.html)⁉️ 答:因為 [`aws elasticbeanstalk create-environment`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticbeanstalk/create-environment.html) 無法指定 region、VPC 等配置。 ::: ## 上傳 `Dockerrun.aws.json` 至 S3 ```shell % aws s3 cp \ {local-path} \ {s3-url} ``` ## 創建 application version ```shell % aws elasticbeanstalk create-application-version \ --application-name eb-docker \ --version-label {version-label} \ --source-bundle S3Bucket={s3-buckey-name},S3Key={s3-key} ``` ## 部署 application version ```shell % eb deploy \ --version {version} \ {environment-name} ``` ## 相關筆記 - [**`eb init`** and **`eb create`**](https://hackmd.io/@pclin/Sy-2SIa0c) ## 參考資料 - AWS CLI Command Reference - [`aws s3 cp`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/cp.html) - [`aws elasticbeanstalk create-application-version`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticbeanstalk/create-application-version.html)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up