amazon-web-services - !GetAtt 参数错误需要 2 个参数,但模板文件似乎不符合此要求

标签 amazon-web-services yaml aws-cloudformation tableau-api

我正在尝试将 Tableau 部署到 AWS gov-cloud,并对模板进行了一些编辑,以便为 govCloud 部署做好准备,但是当我将 YAML 文件上传到 AWS 时,我不断收到以下错误:

Template error: if specifying one argument to Fn::GetAtt, that argument must be a non-empty string in format <LogicalId>.<Attribute>

我没有编辑模板中的任何 !GetAtt 内容,并且模板似乎不遵循该顺序,所以我很困惑为什么我会在上传时不断收到此错误。下面是我的 YAML 文件片段,我会隔离错误,但实际上不确定是哪个部分导致了问题。

AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS CloudFormation Template: Single-node Tableau Server running on Windows,
  CentOS, or Ubuntu. (qs-1puphiil4)'
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: AWS Environment and Machine Configuration
        Parameters:
          - KeyPairName
          - AvailabilityZones
          - VPCCIDR
          - PublicSubnet1CIDR
          - PublicSubnet2CIDR
          - SourceCIDR
          - InstanceType
          - AMIOS
      - Label:
          default: Secrets
        Parameters:
          - Username
          - Password
          - TableauServerAdminUser
          - TableauServerAdminPassword
      - Label:
          default: Registration
        Parameters:
          - AcceptEULA
          - TableauServerLicenseKey
          - RegFirstName
          - RegLastName
          - RegEmail
          - RegCompany
          - RegTitle
          - RegDepartment
          - RegIndustry
          - RegPhone
          - RegCity
          - RegState
          - RegZip
          - RegCountry
      - Label:
          default: AWS Quick Start Configuration
        Parameters:
          - QSS3BucketName
          - QSS3KeyPrefix
    ParameterLabels:
      AcceptEULA:
        default: Accept Tableau End User License Agreement
      AvailabilityZones:
        default: Availability Zones
      AMIOS:
        default: AMI Operating System
      InstanceType:
        default: Tableau Amazon EC2 instance type
      KeyPairName:
        default: Key Pair Name
      Password:
        default: Tableau Services Manager (TSM) administrator password
      PublicSubnet1CIDR:
        default: Public Subnet 1 CIDR
      PublicSubnet2CIDR:
        default: Public Subnet 2 CIDR
      QSS3BucketName:
        default: Quick Start S3 Bucket Name
      QSS3KeyPrefix:
        default: Quick Start S3 Key Prefix
      RegCity:
        default: City
      RegCompany:
        default: Company
      RegCountry:
        default: Country
      RegDepartment:
        default: Department
      RegEmail:
        default: Email Address
      RegFirstName:
        default: First Name
      RegIndustry:
        default: Industry
      RegLastName:
        default: Last Name
      RegPhone:
        default: Phone
      RegState:
        default: State
      RegTitle:
        default: Title
      RegZip:
        default: Zip/Postal Code
      SourceCIDR:
        default: Source CIDR for Access
      TableauServerAdminPassword:
        default: Tableau Server administrator password
      TableauServerAdminUser:
        default: Tableau Server administrator username
      TableauServerLicenseKey:
        default: Tableau Activation Key
      Username:
        default: Tableau Services Manager (TSM) administrator username
      VPCCR:
        default: VPC CIDR
Parameters:
  AvailabilityZones:
    Description: 'List of Availability Zones to use for the subnets in teh VPC, Note: The logical order is preseved and 2 AZs will be used for this deployment'
    Type: List<AWS::EC2::AvailabilityZone::Name>
  AMIOS:
    AllowedValues:
      - Windows
      - CentOS-7-HVM
      - Ubuntu-Server-16.04-LTS-HVM
    Default: Ubuntu-Server-16.04-LTS-HVM
    Description: Operating System on which Tableau Server will be deployed
    Type: String
  AcceptEULA:
    AllowedPattern: 'yes'
    AllowedValues:
      - 'yes'
      - 'No'
    Description: 'View the EULA at the Link: https://www.tableau.com/eula'
    Type: String
  InstanceType:
    AllowedValues:
      - m4.2xlarge
      - m4.4xlarge
      - m4.10xlarge
      - m5.4xlarge
      - m5.12xlarge
      - c5.4xlarge
      - c4.4xlarge
      - c5d.4xlarge
      - r5d.4xlarge
    ConstraintDescription: must be a valid EC2 instance type.
    Default: m5.4xlarge
    Description: Amazon EC2 instance type
    Type: String
  KeyPairName:
    ConstraintDescription: must be the name of an existing EC2 KeyPair.
    Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
    Type: AWS::EC2::KeyPair::KeyName
  Password:
    Description: Tableau Services Manager (TSM) administrator password
    NoEcho: 'true'
    Type: String
  PublicSubnet1CIDR:
    AllowedPattern: '[a-zA-Z0-9]+\..+'
    Default: 10.0.128.0/20
    Description: CIDR Block for the Public DMZ Subnet located in AZ1
    Type: String
  PublicSubnet2CIDR:
    AllowedPattern: '[a-zA-Z0-9]+\..+'
    Default: 10.0.144.0/20
    Description: CIDR Block for the Public DMZ Subnet located in AZ2
    Type: String
  QSS3BucketName:
    AllowedPattern: ^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$
    ConstraintDescription: Quick Start bucket name can include numbers, lowercase
      letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen
      (-).
    Default: aws-quickstart
    Description: S3 bucket name for the Quick Start assets. This string can include
      numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start
      or end with a hyphen (-).
    Type: String
  QSS3KeyPrefix:
    AllowedPattern: ^[0-9a-zA-Z-/]*$
    ConstraintDescription: Quick Start key prefix can include numbers, lowercase letters,
      uppercase letters, hyphens (-), and forward slash (/).
    Default: quickstart-tableau-server/
    Description: S3 key prefix for the Quick Start assets. Quick Start key prefix
      can include numbers, lowercase letters, uppercase letters, hyphens (-), and
      forward slash (/).
    Type: String
  RegCity:
    Description: City
    Type: String
  RegCompany:
    Description: Company
    Type: String
  RegCountry:
    Description: Country
    Type: String
  RegDepartment:
    Description: Department
    Type: String
  RegEmail:
    Description: Email
    MinLength: '1'
    Type: String
  RegFirstName:
    Description: First Name
    MinLength: '1'
    Type: String
  RegIndustry:
    Description: Industry
    Type: String
  RegLastName:
    Description: Last Name
    MinLength: '1'
    Type: String
  RegPhone:
    Description: Phone
    Type: String
  RegState:
    Description: State
    Type: String
  RegTitle:
    Description: Title
    Type: String
  RegZip:
    Description: ZIP/Postal Code
    Type: String
  SourceCIDR:
    AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
    ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/x
    Description: The CIDR address from which you will connect to the instance
    Type: String
  TableauServerAdminPassword:
    Description: The password of the initial administrator for Tableau Server
    MinLength: '1'
    NoEcho: 'true'
    Type: String
  TableauServerAdminUser:
    Description: The name of the initial administrator for Tableau Server
    MinLength: '1'
    Type: String
  TableauServerLicenseKey:
    Description: License Key (leave blank for trial)
    Type: String
  Username:
    AllowedPattern: ^(?!(tableau|tsmagent|admin|root)$)[A-Za-z0-9]*$
    Description: Tableau Services Manager (TSM) administrator username (cannot be
      'tableau' or 'tsmagent' or 'admin' or 'root')
    MaxLength: '30'
    Type: String
  VPCCIDR:
    AllowedPattern: '[a-zA-Z0-9]+\..+'
    Default: 10.0.0.0/16
    Description: CIDR Block for the VPC
    Type: String
Conditions:
  InfaOnWindows: !Equals
    - !Ref 'AMIOS'
    - Windows
  InfaOnCentos: !Equals
    - !Ref 'AMIOS'
    - CentOS-7-HVM
Resources:
  VPCStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub 'https://${QSS3BucketName}.s3.amazonaws-us-gov.com/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template'
      Parameters: 
        AvailabilityZones: !Join
          - ','
          - !Ref 'AvailabilityZones'
        KeyPairName: !Ref 'KeyPairName'
        NATInstanceType: t2.small
        NumberOfAZs: '2'
        PublicSubnet1CIDR: !Ref 'PublicSubnet1CIDR'
        PublicSubnet2CIDR: !Ref 'PublicSubnet2CIDR'
        CreatePrivateSubnets: 'false'
        VPCCIDR: !Ref VPCCIDR
  TableauIAMRole:
    Type: AWS::IAM::Role
    Properties:
      Path: /
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          Effect: Allow
          Principal:
            Service: ec2.amazonaws.com
          Action: sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws-us-gov:iam::aws:policy/service-role/AmazonEC2RoleforSSM
      Policies:
        - PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Action:
                  - s3:GetObject
                Resource:
                  - !Sub 'arn:aws-us-gov:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*'
                Effect: Allow
          PolicyName: aws-quick-start-s3-policy
  TableauServerInstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: /
      Roles:
        - !Ref 'TableauIAMRole'
  WorkloadStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: VPCStack
    Properties:
      TemplateURL: !Sub
        - https://${QSS3BucketName}.s3.amazonaws-us-gov.com/${QSS3KeyPrefix}templates/${QSTableauWorkloadTemplate}
        - QSTableauWorkloadTemplate: !If
            - InfaOnWindows
            - tableau-single-server-windows.template
            - !If
              - InfaOnCentos
              - tableau-single-server-centos.template
              - tableau-single-server-ubuntu.template
      Parameters:
        AMIOS: !Ref 'AMIOS'
        PublicSubnetId: !Ref 'VPCStack.Outputs.PublicSubnet1ID'
        AcceptEULA: !Ref 'AcceptEULA'
        InstanceType: !Ref 'InstanceType'
        KeyPairName: !Ref 'KeyPairName'
        Password: !Ref 'Password'
        QSS3BucketName: !Ref 'QSS3BucketName'
        QSS3KeyPrefix: !Ref 'QSS3KeyPrefix'
        RegCity: !Ref 'RegCity'
        RegCompany: !Ref 'RegCompany'
        RegCountry: !Ref 'RegCountry'
        RegDepartment: !Ref 'RegDepartment'
        RegEmail: !Ref 'RegEmail'
        RegFirstName: !Ref 'RegFirstName'
        RegIndustry: !Ref 'RegIndustry'
        RegLastName: !Ref 'RegLastName'
        RegPhone: !Ref 'RegPhone'
        RegState: !Ref 'RegState'
        RegTitle: !Ref 'RegTitle'
        RegZip: !Ref 'RegZip'
        SourceCIDR: !Ref 'SourceCIDR'
        TableauServerAdminPassword: !Ref 'TableauServerAdminPassword'
        TableauServerAdminUser: !Ref 'TableauServerAdminUser'
        TableauServerLicenseKey: !Ref 'TableauServerLicenseKey'
        Username: !Ref 'Username'
        VPCId: !GetAtt 'VPCID'
Outputs:
  VPCID:
    Description: VPC ID
    Value: !GetAtt 'VPCStack.Outputs.VPCID'
  InstanceID:
    Description: EC2 InstanceID of the instance running Tableau Server
    Value: !GetAtt 'WorkloadStack.Outputs.InstanceID'
  PublicIPAddress:
    Description: Public IP Address of instance running Tableau Server
    Value: !GetAtt 'WorkloadStack.Outputs.PublicIPAddress'
  TableauServicesManagerURL:
    Description: URL for the TSM Web UI
    Value: !GetAtt 'WorkloadStack.Outputs.TableauServicesManagerURL'
  TableauServerURL:
    Description: URL for the Tableau Server
    Value: !GetAtt 'WorkloadStack.Outputs.TableauServerURL'

最佳答案

CloudFormation Linter还可以通过提供更多信息的消息更快地捕获这些错误,例如:

E1010 资源/WorkloadStack/Properties/Parameters/VPCId/Fn::GetAtt 的 GetAtt 无效 template.yaml:333:9

所以我们知道问题出在第 333 行:

        VPCId: !GetAtt 'VPCID'

Visual Studio Code extension还可以在模板中突出显示这些内联内容:

Visual Studio Code extension screenshot


AWS::CloudFormation::Stack return values

Fn::GetAtt documentation


It looks like this line has been updated in the source repository ,但如果您在使用他们的模板时仍然遇到困难,我建议您在那里打开一个 Github 问题

关于amazon-web-services - !GetAtt 参数错误需要 2 个参数,但模板文件似乎不符合此要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60803080/

相关文章:

ruby-on-rails - ActiveRecord 使用 JSON 而不是 YAML 进行序列化

amazon-web-services - 通过 cloudFormation 模板启用日志记录 S3?

php - 我找到了一个链接,但我不知道那是什么

amazon-web-services - 为什么 codepipeline 需要 KMS key ?

javascript - 我的文本在 YAML(.yml) 文件中,我想以粗体显示一些文本

Jenkins Cloudformation 插件 - 无需执行任何更新

amazon-web-services - 如何查询AWS堆栈输出?

amazon-web-services - AWS SageMaker 数据准备

linux - 无法ssh到远程服务器

c# - C# 的商业 YAML 解析器