在AWS cloudformation中创建公钥,出现以下错误:提供了无效的请求:AWS :: CloudFront :: PublicKey [英] Public key creation in AWS cloudformation giving following error: Invalid request provided: AWS::CloudFront::PublicKey

查看:68
本文介绍了在AWS cloudformation中创建公钥,出现以下错误:提供了无效的请求:AWS :: CloudFront :: PublicKey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Cloudformation模板(.yml文件),我在其中创建要添加到密钥组的公共密钥,该密钥也是在同一模板中创建的.(下面的公共密钥仅作为示例.)

I have the following Cloudformation template (.yml file) where I am creating Public key to add to a Keygroup, also created in same template. (The public key below is just for example purpose.)

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  CloudfrontPublicKey:
    Type: AWS::CloudFront::PublicKey
    Properties:
      PublicKeyConfig:
        CallerReference: 'some-caller-reference'
        Comment: 'Public key for signed url'
        Name: 'cloudfront-public-key'
        EncodedKey: '-----BEGIN PUBLIC KEY-----aaaabbbb-----END PUBLIC KEY-----'
  CloudFrontKeyGroup:
    Type: AWS::CloudFront::KeyGroup
    Properties:
      KeyGroupConfig:
        Comment: 'Key group for signed url'
        Items:
          - !Ref CloudfrontPublicKey
        Name: 'cloudfront-key-group'

但是,我遇到以下与公钥有关的错误

However, I am getting the following error relating to the public key

  Invalid request provided: AWS::CloudFront::PublicKey

原始公钥是多行的,例如:

The original public key is multi-line, for example:

-----BEGIN PUBLIC KEY-----
aaaa
bbbb
-----END PUBLIC KEY-----

我尝试通过如下添加新行字符来使其适合单行

I tried to make it fit in single line by adding new line character as follows

-----BEGIN PUBLIC KEY-----\naaaa\nbbbb\n-----END PUBLIC KEY-----

我也尝试了不使用换行符

I also tried without the new line character

-----BEGIN PUBLIC KEY-----aaaabbbb-----END PUBLIC KEY-----

两次尝试均无效,并且仍然出现相同的错误.

Both attempts did not work, and I am still getting the same error.

推荐答案

通常,在这种情况下,您可以在Yaml中使用多行字符串.因此,您可以尝试使用以下版本的模板:

Usually, you can use multi-line strings in yaml for that kind of situations. Thus you may try the following version of the template:

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  CloudfrontPublicKey:
    Type: AWS::CloudFront::PublicKey
    Properties:
      PublicKeyConfig:
        CallerReference: 'some-caller-reference'
        Comment: 'Public key for signed url'
        Name: 'cloudfront-public-key'
        EncodedKey: |
          -----BEGIN PUBLIC KEY-----
          aaaa
          bbbb
          -----END PUBLIC KEY-----

  CloudFrontKeyGroup:
    Type: AWS::CloudFront::KeyGroup
    Properties:
      KeyGroupConfig:
        Comment: 'Key group for signed url'
        Items:
          - !Ref CloudfrontPublicKey
        Name: 'cloudfront-key-group'

这篇关于在AWS cloudformation中创建公钥,出现以下错误:提供了无效的请求:AWS :: CloudFront :: PublicKey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆