问题描述
AWS 新手。我在 CF 模板下面创建了将 s3 存储桶中的 java.exe 复制到 Windows 并安装它。但是,我没有看到首先复制的可执行文件。有人可以指导我了解这里的问题吗?
AWstemplateFormatVersion: 2010-09-09
Description: >-
Cloud Formation template snippet to install Java JDK on Windows
Server 2012 R2. (c) 2017 Air11 Technology LLC -- licensed under the Apache
OpenSource 2.0 license,https://opensource.org/licenses/Apache-2.0
Metadata: {}
Parameters: {}
Rules: {}
Mappings: {}
Resources:
JavaSeleniumEC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
KeyName: 'windowskeypair'
ImageId: ami-0093d2a4365944361
InstanceType: 't2.micro'
IamInstanceProfile: <Existing IAM Role which has EC2 Full access to S3>
Metadata:
'AWS::CloudFormation::Init':
config:
files:
c:\\jdk-11.0.9_windows-x64_bin.exe:
source: "https://<mybucket>.s3.amazonaws.com/jdk-11.0.9_windows-x64_bin.exe"
c:\\Install-Java-JDK.ps1:
content: !Join
- ''
- - 'Set-Location C:\\;'
- '.\\jdk-11.0.9_windows-x64_bin.exe /s'
commands:
command: >-
powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\Install-Java-JDK.ps1
waitAfterCompletion: '60'
解决方法
AWS::CloudFormation::Init
不会自行执行。您必须使用 UserData
在您的 cfn-init.exe
中显式执行。执行此操作的一个示例显示为 here。您必须找到更多有关如何在 Windows 上准确执行此操作的信息。