簡體   English   中英

為什么在為 aws 服務目錄構建此 terraform 模板時出現無效模板主體錯誤?

[英]Why am I getting a Invalid template body error when building this terraform template for aws service catalog?

這是我正在構建的 aws 服務目錄的 terraform 模板。

resource "aws_servicecatalog_product" "data-ml-pipeline-service-catalog-product" {
  name  = "data-ml-pipeline-service-catalog-product"
  owner = "data-ml"
  type  = "CLOUD_FORMATION_TEMPLATE"

  provisioning_artifact_parameters {
    template_url = "https://s3.amazonaws.com/cf-templates-ozkq9d3hgiq2-us-east-1/temp1.json"
    type  = "CLOUD_FORMATION_TEMPLATE"
  }

基於這個問題Terraform /AWS aws_servicecatalog_portfolio ,這應該可行。

確切錯誤: Error: error creating Service Catalog Product: InvalidParametersException: Invalid templateBody. Please make sure that your template is valid Error: error creating Service Catalog Product: InvalidParametersException: Invalid templateBody. Please make sure that your template is valid

編輯:這是我正在使用的新模板。

--- 
ModelBuildCodeCommitRepository: 
  Properties: 
    Code: 
      BranchName: main
      S3: 
        Bucket: sagemaker-servicecatalog-seedcode-us-west-2
        Key: toolchain/image-build-model-building-workflow-v1.0.zip
    RepositoryDescription: 
      ? "Fn::Sub"
      : "SageMaker Model building workflow infrastructure as code for the Project ${SageMakerProjectName}"
    RepositoryName: 
      ? "Fn::Sub"
      : "sagemaker-${SageMakerProjectName}-${SageMakerProjectId}-modelbuild"
  Type: "AWS::CodeCommit::Repository"
Parameters: 
  SageMakerProjectId: 
    Description: "Service-generated id of the project"
    NoEcho: true
    Type: String
  SageMakerProjectName: 
    AllowedPattern: "^[a-zA-Z](-*[a-zA-Z0-9])*"
    Description: "Name of the project"
    MaxLength: 32
    MinLength: 1
    NoEcho: true
    Type: String

我想對此錯誤消息提供一個一般性的答案。
AFAIK, InvalidParametersException: Invalid templateBody. Please make sure that your template is valid InvalidParametersException: Invalid templateBody. Please make sure that your template is valid ,這意味着AWS 無法訪問您嘗試從中創建服務目錄產品版本的模板(通常由密鑰LoadTemplateFromURL提供的模板)。 這有兩個可能的原因:

  • 部署模板URL無效。 確保提供的 URL 實際上指向模板文件。 將 Cloudformation 與 URL 中的變量一起使用時,請確保使用!Sub等。
  • 執行部署的 IAM 用戶/角色可能沒有所需的權限,如另一個 SO 問題所示。 確保權限cloudFormation:validateTemplate已到位。

基本上,此錯誤消息具有誤導性,因為它表明模板無效,但實際上甚至無法在第一時間訪問模板。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM