Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

462
Vistas
AWS SAM: can we use a already existing api in aws sam template?

I have a lambda function that needs to be triggered via Amazon API Gateway. Is there a way to include an already existing API (created using the AWS console) into AWS SAM template?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

SAM doesn't support the !ImportValue in the template yet.

Issue on Github

On the GitHub of the aws/serverless-application-model there's an open PR for that feature

See here

If you want you could help and contribute to that PR so then you could start using !ImportValue in your SAM template.yml

Else, I suggest you go with the old way, you create a CI/CD with a CloudFormation template that can use the !ImportValue and is linked to an S3 bucket where your lambda function code lives.

Examples of Cloudformation Templates

Update

SAM CLI now support the !ImportValue, the issue on Github is closed.

You can use it as follow

# You need to export the resource that you want to use in another template first

# This goes at the end of your template.yml file, after the Resources

# template.yml in the first repo
Outputs:
    myExportedResource:
        Value: !Ref TheResource
        Export:
            Name: !Sub "{environment}-nice-export-name"


# template.yml in the second repo (This obviously goes in Resources)
    MyLambda:
        Type: AWS::Serverless::Function
        Properties:
            FunctionName: awesome-lambda
            CodeUri: ./dist
            Handler: this-file.handler
            Role: !GetAtt LambdaRole.Arn
            VpcConfig:
                SecurityGroupIds:
                    - !GetAtt SecurityGroup.GroupId
                SubnetIds:
                    - Fn::ImportValue: !Sub "${environment}-nice-export-name"

You can use it exactly as a normal cloudformation template

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

Note that here I used Fn:ImportValue because I needed to use !Sub but if you don't need to reference a parameter in your import value simply use !ImportValue

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda