Joey Yi Zhao
Joey Yi Zhao

Reputation: 42556

Why export s3 bucket name and arn use different syntax in serverless framework?

I have below configuration for serverless.yml. It creates a s3 bucket and exports its ARN and Name. What I don't understand is why the bucket ARN value is get by Fn::GetAtt:: S3Bucket Arn but the bucket name is get by Ref S3Bucket. What is the different between these two syntax?

...
  Outputs:
    AttachmentsBucketArn:
      Value:
         Fn::GetAtt:
          - S3Bucket
          - Arn
      Export:
        Name: ${self:custom.stage}-ExtAttachmentsBucketArn

    AttachmentsBucketName:
      Value:
        Ref: S3Bucket
      Export:
        Name: ${self:custom.stage}-ExtAttachmentsBucket

Upvotes: 2

Views: 1582

Answers (1)

Marcin
Marcin

Reputation: 238517

They map directly to return values of AWS::S3::Bucket in CloudFormation.

As the link explains, the use of:

  • Ref "returns the bucket name"
  • GetAtt with Arn "returns the Amazon Resource Name (ARN) of the specified bucket."

Upvotes: 4

Related Questions