Giter VIP home page Giter VIP logo

Comments (5)

fade2black avatar fade2black commented on May 28, 2024 1

I got you. Thank you.

from serverless-application-model.

moelasmar avatar moelasmar commented on May 28, 2024

As per the CFN service docs for resolving Secrets Manager secrets, you need to do a change to the resource that is referring to the secret manager secrets, so CFN detect the update, and update this resource

see the below paragraph as I quoted from the CFN docs

Updating a secret in Secrets Manager doesn't automatically update the secret in CloudFormation. In order for CloudFormation to update a secretsmanager dynamic reference, you must perform a stack update that updates the resource containing the dynamic reference, either by updating the resource property that contains the secretsmanager dynamic reference, or updating another of the resource's properties.
For example, suppose in your template you specify the MasterPassword property of an AWS::RDS::DBInstance resource to be a secretsmanager dynamic reference, and then create a stack from the template. You later update that secret's value in Secrets Manager, but don't update the AWS::RDS::DBInstance resource in your template. In this case, even if you perform a stack update, the secret value in the MasterPassword property isn't updated, and remains the previous secret value.

My suggestion is to add a dummy environment variable to your lambda function, and to change its value every time you have an update in your secrets, so when you trigger a stack deployment, the lambda function will get updated, and retrieve the new secret values.

ExportFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: MyFunction
      PackageType: Image
      Architectures:
      - x86_64
      MemorySize: 2048
      Timeout: 60
      Environment:
        Variables:
          DUMMY: 1
          USER:   !Sub '{{resolve:secretsmanager:mysecret:SecretString:user}}'
          PASSWORD:   !Sub '{{resolve:secretsmanager:mysecret:SecretString:password}}'

I tested this approach, and was working fine for me. I tried to change the Secrets values, and then increment the DUMMY environment variable value, and then deploy the updated template, and found the function environment variables got update with the new values.

from serverless-application-model.

moelasmar avatar moelasmar commented on May 28, 2024

Please let us know if this suggestion helps to solve your problem.

from serverless-application-model.

moelasmar avatar moelasmar commented on May 28, 2024

I will close this issue. Please open a new one if you have any more questions.

from serverless-application-model.

github-actions avatar github-actions commented on May 28, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

from serverless-application-model.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.