我有一个简单的 Windows Powershell 脚本,我希望它在 Elastic Beanstalk 环境中启动时在 EC2 实例上运行。它只是设置一个自签名 SSL 证书并将其绑定(bind)到 IIS 中的默认网站。
我知道这可以通过使用 UserData 单独使用 EC2 实例来完成(如下所示)......但是如何处理在 EB 环境中启动的任何实例呢?
<powershell>
Import-Module WebAdministration
Set-Location IIS:\SslBindings
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
$c = New-SelfSignedCertificate -DnsName "domain.com" -CertStoreLocation cert:\LocalMachine\My
$c | New-Item 0.0.0.0!443
</powershell>
最佳答案
我不是 Powershell 专家,但您是否考虑过类似的问题:
(例如我的 script.config)并部署它。
命令。注意这里的 Yaml 格式可能会关闭并且
可能会导致部署失败
files: "c:/targetdirectory/my_script.ps1": content: | <powershell> Import-Module WebAdministration Set-Location IIS:\SslBindings New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https $c = New-SelfSignedCertificate -DnsName "domain.com" -CertStoreLocation cert:\LocalMachine\My $c | New-Item 0.0.0.0!443 </powershell> encoding: (encoding format either plain or base64) commands: run_my_script: command: ./my_script.ps1 cwd: "c:/targetdirectory/"
所以基本上,你只是创建一个包含脚本的文件然后运行它。 More info is here .
关于amazon-web-services - 使用 Elastic Beanstalk 在实例启动时运行 Windows Powershell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61345798/