Posts

AWS Lambda Environment Variables

When setting up a lambda function there will most likely be secure information that you don’t want to put into your lambda functions. This is when you want to use environment variables. When declaring environment variables inside the code of your lambda function, add the string “process.env.varable_name” where “variable_name” is any string. Once you’ve declared all your environmental variables, go to your was lambda  function console, and scroll down to the environment variables section. Then add all your “variable_names” to the left side text boxes and on the right enter in the actual value of the variable. You can then, if needed, encrypt the environment variables by using the encryption configuration.

AWS SES Template Creation

AWS has SES (Simple Email Service) which is used to help developers create notification emails. In order to use this feature, you must create a template for an email and then you can send emails. Currently, there is no way to create a template in the AWS console. One of the ways to create one is by using a Node script. You first need to have:

  1. Node installed on your computer
  2. An AWS account with access & secret keys

You will want to enter your account information where the red highlights are. Then you must add a template name (name you will be using when calling template), htmlPart (text in the email in html form), subject (the greetings), and text part (The email body that will be visible to recipients whose email clients do not display HTML).

 

Run the script and check if your template is in your AWS SES dashboard.

AWS Lambda and API Gateway

The following instructions are given that you have a lambda function created that works. AWS has API Gateway which enables developers to create RESTful API endpoints so people can call it and in turn run a lambda function. If you have never set up an API in API Gateway, you must:

  1. Log into the AWS console
  2. Search for “API Gateway” in the services tab
  3. Press “Create API”
  4. Choose REST / New API / assign a name to your api
  5. Once Created, add a resource to you api
  6. Create a method
  7. Add the created lambda function to the api resource

Once you have followed these steps the API Gateway will give you a url where you can call from your code and it will run your lambda function. One last thing you must do is to deploy the API. To do this, go to the resources tab of the API and click the Actions button and then click “Deploy”. Note that you may need to set up CORS if you want to secure your API.

AWS Lambda Sql Connection

If you are creating a web app that uses lambda and a mysql database, there will be many times where you need to have sql information passing to and from lambda functions. A way to connect a lambda functions to a mysql database is using npm mysql. To set up the connection, there must be a connection variable defined. This variable must contain the mysql host name, user, password, and database. Once these are defined, the lambda function can connect to the mysql database with the code “connection.connect()”. Once this is ran, your lambda function can now run queries. These queries are written just like a regular sql query. Once you are done running your query make sure to declare your connection closed by stating “connection.end()”.

The process.env variables would be were you put your sql information.

 

**Note: You might need to configure your lambda function to be set up on the mysql database’s VPC.

AWS (Amazon Web Services) for Dummies

Whether you are a CIO or a SysAdmin, as the world moves to the cloud, all IT professionals need to understand the cloud and be able to speak its language. In this 1 hour webinar, get a quick primer of several of the services available through AWS. Some of the topics covered include:

EC2 – Virtual Servers in the Cloud
S3 – Scalable Storage in the cloud
RDS – Managed Relational Database Service
And several more (Lambda, DynamoDB, Redshift…)

 

Nogalis Webinar: AWS (Amazon Web Services) for Dummies (August 31st, 9 AM PST)

You won’t want to miss this one. Whether you are a CIO or a SysAdmin, as the world moves to the cloud, all IT professionals need to understand the cloud and be able to speak its language.

In this 1 hour webinar, get a quick primer of several of the services available through AWS. We’ll be launching an instance and logging onto it during the webinar. You can follow along if you sign up with AWS ahead of time. Some of the topics we’ll cover:
  • EC2 – Virtual Servers in the Cloud
  • S3 – Scalable Storage in the cloud
  • RDS – Managed Relational Database Service
  • And several more (Lambda, DynamoDB, Redshift…) as time allows

When: Thursday August 31, 2017
9:00 AM to 10:00 AM PST

This webinar is free to attend. Register Now