skip to Main Content

I have built a MERN stack app that I am now attempting to launch on an EC2 instance. I initially had environment variables stored in a .env file for dev. I have transferred these values to AWS parameter store for added security in production. How do I import these values to code?

I have looked for resources online to guide me through the process. So far I have came across lots of posts and videos referring to lambda. Currently, my project does not use lambda. Is this something I should dig deeper into?

2

Answers


  1. Chosen as BEST ANSWER

    The link was very useful.

    Adding the following policy to AWS IAM was needed as well.

        {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Sid": "Statement1",
                    "Effect": "Allow",
                    "Action": [
                        "ssm:GetParameters",
                        "ssm:GetParameter",
                        "ssm:GetParametersByPath"
                    ],
                    "Resource": "arn:aws:ssm:*:*:parameter/*"
                }
            ]
        }
    

    I am able to print the values stored in the parameter store to the console via server code running on the backend. I can't figure out how to store the values in variables to be used throughout the code. Any suggestions here?


  2. Looks like you can import your stored variables using the aws-sdk as shown in this article: https://notificare.com/blog/2021/02/12/Using-Parameter-Store-With-Node/.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search