[英]cfn-init in aws cloudformation can't find metadata
我正在使用 PHP 應用程序和其他一些依賴項設置 cloudformation 堆棧。
我正在嘗試使用啟動配置中的元數據設置配置文件和應用程序。
我的代碼驗證 - yaml 語法和堆棧的其他部分沒有問題,除了 cfn-init 找不到的元數據部分。
我可以確認 cfn-init 使用所需的參數運行。 但由於某種原因找不到元數據。
當我在具有相同參數的實例內運行 aws helper cfn-get-metadata 時,我可以看到元數據一切正常。
有什么幫助嗎? 這是我用於元數據的 cloudformation 片段。 我沒有包含觸發 cfn-init 助手 function 的用戶數據部分。
LaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Metadata:
AWS::CloudFormation::init:
configSets:
app_install:
- configure_cfn
- configure_nginx
- install_packages
configure_cfn:
files:
"/etc/cfn/cfn-hup.conf":
content:
Fn::Join:
- ""
- - "[main]\n"
- stack=
- Ref: AWS::StackId
- "\n"
- region=
- Ref: AWS::Region
- "\n"
mode: "000400"
owner: root
group: root
"/etc/cfn/hooks.d/cfn-auto-reloader.conf":
content:
Fn::Join:
- ""
- - "[cfn-auto-reloader-hook]\n"
- "triggers=post.update"
- "path=Resources.LaunchConfig.Metadata.AWS::CloudFormation::Init"
- "action=/opt/aws/bin/cfn-init -v "
- " --stack "
- Ref: AWS::StackName
- " --resource LaunchConfig "
- " --configsets app_install "
- " --region "
- Ref: AWS::Region
- "\n"
mode: "000400"
owner: root
group: root
configure_nginx:
files:
"/etc/cfn/cfn-hup.conf":
content:
Fn::Join:
- ""
- - "[main]\n"
- stack=
- Ref: AWS::StackId
- "\n"
- region=
- Ref: AWS::Region
- "\n"
mode: "000400"
owner: root
group: root
install_packages:
packages:
yum:
nginx: []
php71: []
php-common: []
php71-fpm: []
php71-devel: []
php71-mcrypt: []
php71-xml: []
php71-common: []
php71-pdo: []
php71-mbstring: []
php7-pear: []
gcc: []
awslogs: []
files:
/etc/nginx/conf.d/app.conf:
content: |
server {
listen 80;
server_name _;
# note that these lines are originally from the "location /" block
root /var/www/app;
autoindex on;
index index.php index.html index.htm;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)\$ {
expires max;
log_not_found off;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
#location ~ \.php$ {
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 30d;
}
location ~ /\.ht {
deny all;
}
}
services:
sysvinit:
cfn-hup:
enabled: true
ensureRunning: true
files:
- "/etc/cfn/cfn-hup.conf"
- "/etc/cfn/hooks.d/cfn-auto-reloader.conf"
nginx:
enabled: true
ensureRunning: true
這么簡單的事情? 初始化與初始化?
AWS::CloudFormation::init: vs AWS::CloudFormation:: I nit:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.