简体   繁体   中英

How to use !ImportValue to get the resource arn using AWS SAM template

I have a base template, output section is like this:

Outputs:
  layerName:
    Value: !Ref Psycopg2LayerLambdaLayer

How to get the arn of Psycopg2LayerLambdaLayer using the output from the base template in my new template? is this correct?

Layers: !ImportValue layerName.arn

If you want to use an Output value as an Import in a different template, you must export it first. In your example, it might look like the following:

Outputs:
  layerArn:
    Value: !GetAtt Psycopg2LayerLambdaLayer.arn
    Export:
      Name: psycopg2LayerArn

After deploying this, you can import the value in another stack with !ImportValue psycopg2LayerArn .

Note that an export has to have a unique name per account and region, therefore it is a good idea to prefix it with the stack/resource name. Also note that you can't export objects, only scalar values such as strings.

Read more at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM