【问题标题】:pull git bash script for aws user data为 aws 用户数据拉取 git bash 脚本
【发布时间】:2018-03-22 10:07:42
【问题描述】:

我是 GIT 新手,有没有办法提取一个包含用户数据的 GIT 脚本以通过 CLI 预置 AWS EC2 实例?

aws ec2 run-instances --image-id ami-cd0f5cb6 --count 1 --instance-type t2.micro 
--key-name ciServer --subnet-id subnet-2f31275b --associate-public-ip-address 
--security-group-ids sg-762a5006 --block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"VolumeSize":20}}]' 
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=My New Server}]' 
--user-data me@git.com/myUserDatarepo.git

【问题讨论】:

  • AMI 中的基本操作系统是什么? Windows 还是 Linux?
  • 这是一个 Ubuntu Server 16.04。如果您还有问题,请告诉我!

标签: git bash amazon-ec2 aws-cli


【解决方案1】:

创建一个 bash 脚本来安装 git,然后将 repo 下载到您需要的地方。将此脚本设为您的用户数据脚本。您必须将 git repo 的凭据获取到 userdata 脚本/服务器。您可以install the AWS cli 并从具有凭据的受保护 s3 存储桶中提取,或使用类似 consul or Hashicorp vault 的东西提取秘密。我通常使用可以访问 git repo 的 ssh key file,一个 s3 存储桶只能由您配置的服务器的 IAM instance role 访问,并且是 encrypted with Server side encryption.

其他问题也讨论这个问题

Is it secure to store EC2 User-Data shell scripts in a private S3 bucket?

How can I (securely) download a private S3 asset onto a new EC2 instance with cloudinit?

AWS System Manager Parameter Store 的新服务

https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-about.html

【讨论】:

  • 这很棒。我认为现在你提到它,走 S3 路线可能更安全,因为目前它似乎最有意义。感谢您的回复!
猜你喜欢
  • 2018-04-30
  • 2019-05-23
  • 2017-01-15
  • 1970-01-01
  • 2016-09-05
  • 1970-01-01
  • 1970-01-01
  • 2013-08-15
  • 2018-05-24
相关资源
最近更新 更多