我正在尝试使用aws-cli启动ec2实例(即ubuntu ami),我想从我之前创建的s3存储桶中复制代码

奖杯

这是我用来启动ec2实例的命令:

aws ec2 run-instances --image-id *ubuntu image id* --count 1 --instance-type t2.micro --key-name new_instance --security-group-ids mysecuity --user-data file://aws.txt

我的aws.txt文件内容:

`#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2 php7.0 php7.0-curl php7.0-cli
sudo service apache2 start
sudo apt-get install -y python3 python-pip
sudo apt-get update && sudo pip install --upgrade --user awscli
mkdir ~/.aws && cd ~/.aws
touch credentials && touch config
echo "[default]" > credentials
echo "aws_access_key_id = *id here*" >> credentials
echo "aws_secret_access_key = *secret key*" >> credentials
echo "[default]" > config
echo "output = json" >> config
echo "region = ap-south-1" >> config`enter code here`
sudo aws s3 sync s3://*bucket name* var/www/html`

但是只有apache2和php被安装。而且mkdir无法正常工作,也未安装awscli,因此我的s3存储桶代码未与ebs卷同步。

安莫尔

可能会在mkdir ~/.aws && cd ~/.aws网上抛出错误,因为“〜”有时指向不同的位置,请改为使用mkdir /home/*username here*/.aws && cd /home/*username here*/.aws它应该可以工作,并尝试在最后的aws行中使用sudo。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章