Aws lambda 使用Sam模板中的参数生成资源逻辑Id名称

Aws lambda 使用Sam模板中的参数生成资源逻辑Id名称,aws-lambda,serverless-framework,Aws Lambda,Serverless Framework,我正在使用Sam模板部署带有api网关的lambda。 尝试基于时间戳生成自定义资源逻辑Id。例如,在下面的示例中:ApiDeployment$TIMESTAMP$:它不起作用。有没有办法使用Sam模板实现动态可配置的资源逻辑Id名称 AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Setup our API Gateway instances Parameter

我正在使用Sam模板部署带有api网关的lambda。 尝试基于时间戳生成自定义资源逻辑Id。例如,在下面的示例中:ApiDeployment$TIMESTAMP$:它不起作用。有没有办法使用Sam模板实现动态可配置的资源逻辑Id名称

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Setup our API Gateway instances

Parameters:
  StageName:
    Type: String
    Default: 'example_stage'
    Description: 'The name of the stage to be created and managed within our API Gateway instance.'

Resources:

  Api:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: ExampleApi
      EndpointConfiguration: 
        Types: 
        - REGIONAL

      # The body should contain the actual swagger
      Body: $SWAGGER_DEFINITION$

  # Timestamp is added so that each deployment is unique. Without a new timestamp, the deployment will not actually occur
  ApiDeployment$TIMESTAMP$:
    Type: AWS::ApiGateway::Deployment
    DependsOn: [ Api ]
    # we want to retain our deployment history
    DeletionPolicy: Retain    
    Properties:
      RestApiId:
        Ref: Api

  ApiStage:
    Type: AWS::ApiGateway::Stage
    DependsOn: [ApiDeployment$TIMESTAMP$]
    Properties:
      RestApiId:
        Ref: Api
      DeploymentId:
        Ref: ApiDeployment$TIMESTAMP$
      StageName: {Ref: StageName}
      MethodSettings:
        - ResourcePath: "/*"
          HttpMethod: "*"
          LoggingLevel: INFO
          MetricsEnabled: true
          DataTraceEnabled: true

Outputs:
  Endpoint:
    Description: Endpoint url
    Value:
      Fn::Sub: 'https://${Api}.execute-api.${AWS::Region}.amazonaws.com'