Откуда берутся эти ссылки в этом фрагменте AWS SAM?

#amazon-web-services #aws-sam

#amazon-web-services #aws-sam

Вопрос:

В этой документации:

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-controlling-access-to-apis-cognito-user-pool.html

вот этот фрагмент шаблона SAM:

 Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Cors: "'*'"
      Auth:
        DefaultAuthorizer: MyCognitoAuthorizer
        Authorizers:
          MyCognitoAuthorizer:
            UserPoolArn: !GetAtt MyCognitoUserPool.Arn

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./src
      Handler: lambda.handler
      Runtime: nodejs12.x
      Events:
        Root:
          Type: Api
          Properties:
            RestApiId: !Ref MyApi
            Path: /
            Method: GET

  MyCognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: !Ref CognitoUserPoolName
      Policies:
        PasswordPolicy:
          MinimumLength: 8
      UsernameAttributes:
        - email
      Schema:
        - AttributeDataType: String
          Name: email
          Required: false
  
  MyCognitoUserPoolClient:
    Type: AWS::Cognito::UserPoolClient
    Properties:
      UserPoolId: !Ref MyCognitoUserPool
      ClientName: !Ref CognitoUserPoolClientName
      GenerateSecret: false
 

Где CognitoUserPoolName и CognitoUserPoolClientName определены?

Ответ №1:

Этот код представляет собой всего лишь фрагмент из шаблона CloudFormation. CognitoUserPoolName и CognitoUserPoolClientName являются строками, которые должны быть указаны вами. Один из способов сделать это — передать их в качестве параметров:

 Parameters:
  CognitoUserPoolName:
    Type: String
    Description: Cognito User Pool name
  CognitoUserPoolClientName:
    Type: String
    Description: Cognito User Pool Client name