简体   繁体   English

Cloud Formation - 无法上传模板文件

[英]Cloud Formation - can't upload template file

I try and create a stack by uploading a template.我尝试通过上传模板来创建堆栈。
That fails with an error heading that is blank.失败,错误标题为空白。

I have permissions to create buckets, upload files, create EC2 instances, etc. I tried switching to my root account even but that didn't help.我有权创建存储桶、上传文件、创建 EC2 实例等。我什至尝试切换到我的根帐户,但这并没有帮助。

I've tried different YAML files and examples but none seem to work.我尝试了不同的 YAML 文件和示例,但似乎都没有。 Without meaningful error messages with actionable items I am stuck.如果没有带有可操作项目的有意义的错误消息,我就会陷入困境。

在此处输入图像描述

在此处输入图像描述

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Metadata": {
        "AWS::CloudFormation::Designer": {
            "213de823-ad0a-4f4c-af04-e3c9e565eef8": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 581,
                    "y": 148
                },
                "z": 0
            }
        }
    },
    "Resources": {
        "EC2I4PJFK": {
            "Type": "AWS::EC2::Instance",
            "Properties": {},
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "213de823-ad0a-4f4c-af04-e3c9e565eef8"
                }
            }
        }
    }
}

Resolution解析度

Had the same issue when trying to upload a template.yml file I had created.尝试上传我创建的template.yml文件时遇到了同样的问题。 My solution was to create a Public Object in S3 and then copy the Object URL into Cloudformation.我的解决方案是在 S3 中创建一个公共 Object,然后将 Object URL 复制到 Cloudformation 中。

The solution proposed by the author did not help me.作者提出的解决方案对我没有帮助。

Debugging调试

Inspecting the console and http requests didn't lead to much unfortunately.不幸的是,检查控制台和 http 请求并没有带来太多结果。 The request to: https://console.aws.amazon.com/cloudformation/service/upload/uploadSuccess?bucket=cf-templates-jcexs078zt-us-east-1&key=somekey-template.yml&etag=someetag请求: https://console.aws.amazon.com/cloudformation/service/upload/uploadSuccess?bucket=cf-templates-jcexs078zt-us-east-1&key=somekey-template.yml&etag=someetag

Returns a 200.返回 200。

Request Headers:请求标头:

Host: console.aws.amazon.com
Referer: https://console.aws.amazon.com/cloudformation/home?region=us-east-1
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36

Response Headers:响应标头:

Cache-Control: private, no-cache, no store
Connection: keep-alive
Content-Length: 0
Date: Sun, 31 May 2020 00:05:20 GMT
Expires: Sat, 30 May 2020 00:05:20 GMT
Pragma: no-cache
Server: Server
Strict-Transport-Security: max-age=47304000; includeSubDomains
Vary: Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent
x-amz-rid: {sensitive-info?}
X-CloudFormation-RequestId: 885b8352-3178-4658-8326-b6a696a89579

Expected Behavior预期行为

I would expect my file to be uploaded to s3 automatically, and if it fails I would expect a meaningful error message to be returned and displayed.我希望我的文件会自动上传到 s3,如果失败,我希望返回并显示一条有意义的错误消息。

Adding following policy to my role(in your case, it may be a role or a user) worked for me:将以下策略添加到我的角色(在您的情况下,它可能是角色或用户)对我有用:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::cf-template*"
        }
    ]
}

From AWS Support....来自 AWS 支持......

If you're using "Chrome" browser and seeing this issue, please try to clear cookies/browser cache, quit the browser and login again to AWS Console and try to create the stack [1].如果您使用“Chrome”浏览器并看到此问题,请尝试清除 cookie/浏览器缓存,退出浏览器并再次登录 AWS 控制台并尝试创建堆栈 [1]。 Additionally, try after disabling browser extensions.此外,请在禁用浏览器扩展后尝试。 [2] [2]

Workarounds: - You can try with any other browser and see if the stack creation is successful.解决方法: - 您可以尝试使用任何其他浏览器并查看堆栈创建是否成功。 - You can manually upload the template to an S3 bucket and reference the S3 URL while creating the stack. - 您可以手动将模板上传到 S3 存储桶,并在创建堆栈时引用 S3 URL。 - You may also use AWS CLI to create the stack.[3] - 您也可以使用 AWS CLI 创建堆栈。[3]

[1]: Clear Cache and Cookies on Chrome: https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en [1]:在 Chrome 上清除缓存和 Cookies: https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en

[2]: Manage extensions on Chrome:https://support.google.com/chrome_webstore/answer/2664769?hl=en [2]:在 Chrome 上管理扩展程序:https://support.google.com/chrome_webstore/answer/2664769?hl=en

[3]: CLI Command reference to create stack: https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html [3]:创建堆栈的 CLI 命令参考: https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html

I think to upload the file to s3 and paste the s3 URI is the only workaround right now.我认为将文件上传到 s3 并粘贴 s3 URI 是目前唯一的解决方法。

I was in the wrong region我在错误的地区

Once I switched to us-east-1 (Virginia) in the management console itself, all these problems went away.一旦我在管理控制台本身切换到 us-east-1(弗吉尼亚州),所有这些问题都消失了。 When I switch to another region they return.当我切换到另一个区域时,它们会返回。 The template also refers to resources in us-east-1.该模板还引用了 us-east-1 中的资源。 So this explains how to avoid the error, however the poor (even blank) error messages are very unhelpful.所以这解释了如何避免错误,但是糟糕的(甚至是空白的)错误消息非常无用。 I am still not sure if the other region AMI ref is the issue or whether you just need to be in N. Virginia to run cd.我仍然不确定其他地区的 AMI 参考是否是问题,或者您是否只需要在弗吉尼亚北部运行 cd。

At one point I had even got the template to execute (though resource created still failed) by using an S3 bucket that I had created for the template file instead of the upload file functionality.有一次,我什至使用我为模板文件创建的 S3 存储桶而不是上传文件功能来执行模板(尽管创建的资源仍然失败)。 When I used the 'load from S3 bucket' approach it actually uploaded but then failed in stack creation due to the wrong region issue (AMIs for example are region specific).当我使用“从 S3 存储桶加载”方法时,它实际上已上传,但由于错误的区域问题(例如,AMI 是特定于区域的)而导致堆栈创建失败。 This just added to the confusion when debugging the issue.这只是在调试问题时增加了混乱。

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

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