本章節使用GitLab-CI, AWS CodePipeLine, AWS CodeDeploy, AWS CLI, AWS S3, AWS EC2等工具部屬
安裝 AWS CLI
https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/installing.html
windows
- download python
- 設定 python 環境變數
1
2
|
python → C:\Users\Scott\AppData\Local\Programs\Python\Python37
pip → C:\Users\Scott\AppData\Local\Programs\Python\Python37\Scripts
|
- Install aws-cli
1
|
pip install --user --upgrade awscli
|
安裝完成時會顯示套件安裝路徑
將此路徑設定到環境變數
1
2
3
4
|
C:\Users\Scott>pip install --user --upgrade awscli
Requirement already up-to-date: awscli in c:\users\scott\appdata\roaming\python\python37\site-packages (1.15.66)
Requirement not upgraded as not directly required: botocore==1.10.65 in
...
|
- 安裝成功訊息
1
2
|
C:\Users\Scott>aws --version
aws-cli/1.15.66 Python/3.7.0 Windows/10 botocore/1.10.65
|
- Uninstall aws-cli
Ubuntu
- Install aws-cli
1
2
3
|
# AWS CLI requires python-pip, python is installed by default
sudo apt-get install -y python3 python3-pip
pip3 install awscli
|
- run aws s3
1
2
3
4
5
6
7
|
aws configure set aws_access_key_id $ACCESS_KEY
aws configure set aws_secret_access_key $SECRET_KEY
aws configure set default.region ap-southeast-1
aws configure set default.outupt json
uname -a > ~/ec2-info.txt
aws s3 cp ~/ec2-info.txt s3://$BUCKET_NAME/ec2-info.txt
|
EC2機器需安裝 CodeDeploy agent 和設定 IAM
-
https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-ubuntu.html
-
IAM roles參考 : CodeDeploySampleStack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
{
"Statement": [
{
"Action": [
"autoscaling:Describe*",
"cloudformation:Describe*",
"cloudformation:GetTemplate",
"s3:Get*"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
|