aws配置eb-cli

EB CLI 是 Elastic Beanstalk 的命令行界面,它提供了可简化从本地存储库创建、更新和监控环境的交互式命令。将 EB CLI 用作每日开发和测试周期的一部分,取代 AWS 管理控制台。

Prerequisites

  • Larger than Python 2.7 or Python3.4

安装EB CLI

1
2
3
4
5
6
7
# 可选参数 --upgrade更新依赖组件 --user安装到用户子目录
pip install awsebcli
# 设置Env, eg: LOCAL_PATH=~/.local/bin
export PATH=LOCAL_PATH:$PATH
source ~/.bashrc
# Check eb version
eb --version

配置 EB CLI

1
2
3
4
5
6
7
8
9
10
11
12
13
# Maven package 激活pro的profile打入ebextensions的nginx配置
cd my-app && mvnw clean package -Dmaven.test.skip=true
# EB init
eb init
# EB create env profile
eb create
# EB deploy
eb deploy
# EB logs
eb logs
# 登录 EB Instance 检查详细日志
# eb ssh
# tailf /var/log/nginx/access.log

配置示例(cat .elasticbeanstalk/config.yml)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
branch-defaults:
master:
environment: my-app-dev
group_suffix: null
release:
environment: my-app-dev
group_suffix: null
deploy:
# 需要上传java包的路径
artifact: target/my-app.war
global:
application_name: my-app
branch: null
default_ec2_keyname: mypem
default_platform: Java 8
default_region: us-east-1
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: git
workspace_type: Application

反向代理配置

1
2
3
4
5
6
7
8
9
10
#### Nginx配置如何生效
- 目录结构如下:
my-app.war
|-- .ebextensions
| `-- nginx
| `nginx.conf
| `agent_deny
`-- org
`--META-INF
`--WEB-INF

Pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--maven package springboot war-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/ebextensions</directory>
<targetPath>.ebextensions</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>

参考链接

分享到