简体   繁体   English

AWS Cloudformation Windows 2016 EC2 S3 静默安装

[英]AWS Cloudformation Windows 2016 EC2 S3 silent install

I have architecture created using CloudFormation utilizing Windows 2016 EC2 server and S3, written in JSON.我使用 CloudFormation 创建了架构,该架构使用 Windows 2016 EC2 服务器和 S3,用 JSON 编写。 I have 7 executables uploaded onto my S3 bucket.我有 7 个可执行文件上传到我的 S3 存储桶中。 I can manually silently install everything from a Powershell for AWS prompt, once I Remote into the EC2.一旦我远程进入 EC2,我可以手动静默安装 Powershell 中的所有内容以获取 AWS 提示。 I can do it one at a time, and even have it in a.ps1 file and run it in Powershell for AWS and it runs correctly.我可以一次做一个,甚至将它放在 a.ps1 文件中并在 Powershell for AWS 中运行它,它运行正常。

I am now trying to get this to install silently when the EC2 instance is created.我现在正试图在创建 EC2 实例时让它静默安装。 I just can't do it and I can't understand why.我就是做不到,我不明白为什么。 The JSON code looks correct. JSON 代码看起来是正确的。 As you can see, I first download everything from the S3 bucket, switch to the c:\TEMP directory where they were all downloaded, then run the executables in unattended install mode.如您所见,我首先从 S3 存储桶下载所有内容,切换到 c:\TEMP 目录,然后在无人值守安装模式下运行可执行文件。 I don't get any errors in my CloudFormation template.我的 CloudFormation 模板中没有任何错误。 It runs "successfully."它运行“成功”。 The problem is that nothing happens.问题是什么都没有发生。 Is it a permissions thing?这是权限的事情吗? Any help is welcome and appreciated.欢迎和赞赏任何帮助。 Thanks!谢谢!

Under the AWS::EC2::Instance section I have the UserData section looking something like this (I shortened the executable names below):在 AWS::EC2::Instance 部分下,我的 UserData 部分看起来像这样(我缩短了下面的可执行文件名称):

    "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
        "<powershell>\n",
        "copy-S3Object -BucketName mySilentInstallBucket -KeyPrefix * -LocalFolder c:\\TEMP\\",
        "\n",
        "cd c:\\TEMP\\",
        "\n",
        "firefox.exe -S ",
        "\n",
        "notepadpp.exe /S",
        "\n",
        "Git.exe /SILENT",
        "\n",
        "</powershell>"
    ]]}}

This troubleshooting doc will cover the various reasons you may not be able to connect to S3: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-access-s3-bucket/此故障排除文档将涵盖您可能无法连接到 S3 的各种原因: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-access-s3-bucket/

To connect to your S3 buckets from your EC2 instances, you need to do the following:要从 EC2 实例连接到 S3 存储桶,您需要执行以下操作:

  1. Create an AWS Identity and Access Management (IAM) profile role that grants access to Amazon S3.创建授予对 Amazon S3 访问权限的 AWS Identity and Access Management (IAM) 配置文件角色。

  2. Attach the IAM instance profile to the instance.将 IAM 实例配置文件附加到实例。

  3. Validate permissions on your S3 bucket.验证 S3 存储桶的权限。

  4. Validate network connectivity from the EC2 instance to Amazon S3.验证从 EC2 实例到 Amazon S3 的网络连接。

  5. Validate access to S3 buckets.验证对 S3 存储桶的访问。

The CloudFormation template won't fail based on UserData execution exceptions. CloudFormation 模板不会因 UserData 执行异常而失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM