# Test to verify that resource references available on the Function are properly resolved
# Currently supported references are:
#    - Alias
#
# Use them by appending the property to LogicalId of the function

Resources:
  MinimalFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/hello.zip
      Handler: hello.handler
      Runtime: python2.7
      AutoPublishAlias: live

  FunctionWithoutAlias:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/hello.zip
      Handler: hello.handler
      Runtime: python2.7

  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      Name:
        Fn::GetAtt: [MinimalFunction.Alias, Name]

Outputs:
  AliasArn:
    Value: !Ref MinimalFunction.Alias

  AliasName:
    Value: !GetAtt MinimalFunction.Alias.Name

  # Alias doesn't exist for this function. This reference must not resolve
  MustNotResolve:
    Value: !GetAtt FunctionWithoutAlias.Alias.Name

  AliasInSub:
    Value:
      Fn::Sub: ['Hello ${MinimalFunction.Alias} ${MinimalFunction.Alias.Name} ${SomeValue}',
        SomeValue: World]

  VersionArn:
    Value: !Ref MinimalFunction.Version
  VersionNumber:
    Value:
      Fn::GetAtt: [MinimalFunction.Version, Version]

  UnResolvedVersion:
    Value:
      Ref: FunctionWithoutAlias.Version