Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Env Documentation #709

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ README.txt
coverage.xml
htmlcov
temp*.py
sendgrid.env
.vscode
sendgrid/VERSION.txt
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ We welcome direct contributions to the sendgrid-python code base. Thank you!
### Development Environment ###
#### There are two ways to get set up: ####
#### 1. Using Docker ####
This is usually the easiest and fastest way to get set up.
This is usually the easiest and fastest way to get set up.
You can use our Docker image to avoid setting up the development environment yourself. See [USAGE.md](https://github.com/sendgrid/sendgrid-python/blob/master/docker/USAGE.md).

#### - OR - ####
Expand All @@ -87,9 +87,14 @@ First, get your free SendGrid account [here](https://sendgrid.com/free?source=se
Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).

```bash
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
cp .env_sample .env
```

Then edit `.env` and insert your API key.

```bash
# You do not need to do this when using Docker Compose
source .env
```

##### Execute: #####
Expand Down Expand Up @@ -184,8 +189,10 @@ Please run your code through:
```bash
# Clone your fork of the repo into the current directory
git clone https://github.com/sendgrid/sendgrid-python

# Navigate to the newly cloned directory
cd sendgrid-python

# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/sendgrid/sendgrid-python
```
Expand Down
57 changes: 57 additions & 0 deletions docker/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,63 @@ $ docker run -it -v /path/to/cool-sendgrid-python:/mnt/sendgrid-python sendgrid/

Note that the paths you specify in `-v` must be absolute.

# Docker Compose

<a name="Quickstart"></a>
# Quickstart

1. Install docker-compose on your machine.
2. Must copy .env_sample to .env file.
3. Edit .env file for yours versions and paths.
4. Must create env folder for clone yours repo.
5. Have fun! :D

## Using tag's for versions - DockerHub:

### Edit variable TAG on .env/env_sample file

```sh-session
$ sed -ie 's/TAG=latest/TAG=choice_a_version/g'
```
### Run service using tags

```sh-session
$ cd /path/to/sendgrid-python/docker
$ docker-compose up -d sendgrid
```

## Specifying specific versions:

### Edit variable TAG on .env/env_sample file

```sh-session
$ sed -ie 's/SENDGRID_PYTHON_VERSION=vy.x.z/SENDGRID_PYTHON_VERSION=vx.y.z/g'
$ sed -ie 's/HTTP_CLIENT_VERSION=vy.x.z/HTTP_CLIENT_VERSION=vx.y.z/g'
```

### Run service

```sh-session
$ cd /path/to/sendgrid-python/docker
$ docker-compose up -d sendgrid-dev
```

## Specifying your own fork:

### Edit variable TAG on .env/env_sample file

```sh-session
$ sed -ie 's/TAG=latest/TAG=choice_a_version/g'
$ sed -ie 's/SENDGRID_PYTHON_VERSION=vy.x.z/SENDGRID_PYTHON_VERSION=vx.y.z/g'
```

### Run service

```sh-session
$ cd /path/to/sendgrid-python/docker
$ docker-compose up -d sendgrid-beta
```

<a name="Testing"></a>
# Testing
Testing is easy! Run the container, `cd sendgrid`, and run `tox`.
Expand Down
1 change: 0 additions & 1 deletion sendgrid.env

This file was deleted.

20 changes: 10 additions & 10 deletions use_cases/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Before starting this tutorial, you will need to have access to an AWS account in
## Getting Started

### Create AWS CodeStar Project
Log in to your AWS account and go to the AWS CodeStar service. Click "Start a project". For this tutorial we're going to choose a Python Web service, utilizing AWS Lambda. You can use the filters on the left hand side of the UI to narrow down the available choices.
Log in to your AWS account and go to the AWS CodeStar service. Click "Start a project". For this tutorial we're going to choose a Python Web service, utilizing AWS Lambda. You can use the filters on the left hand side of the UI to narrow down the available choices.

After you've selected the template, you're asked to provide a name for your project. Go ahead and name it "hello-email". Once you've entered a name, click "Create Project" in the lower right hand corner. You can then choose which tools you want to use to interact with the project. For this tutorial, we'll be choosing "Command Line".
After you've selected the template, you're asked to provide a name for your project. Go ahead and name it "hello-email". Once you've entered a name, click "Create Project" in the lower right hand corner. You can then choose which tools you want to use to interact with the project. For this tutorial, we'll be choosing "Command Line".

Once that is completed, you'll be given some basic steps to get Git installed and setup, and instructions for connecting to the AWS CodeCommit(git) repository. You can either use HTTPS, or SSH. Instructions for setting up either are provided.
Once that is completed, you'll be given some basic steps to get Git installed and setup, and instructions for connecting to the AWS CodeCommit(git) repository. You can either use HTTPS, or SSH. Instructions for setting up either are provided.

Go ahead and clone the Git repository link after it is created. You may need to click "Skip" in the lower right hand corner to proceed.

Once that's done, you've successfully created a CodeStar project! You should be at the dashboard, with a view of the wiki, change log, build pipeline, and application endpoint.
Once that's done, you've successfully created a CodeStar project! You should be at the dashboard, with a view of the wiki, change log, build pipeline, and application endpoint.

### Create SendGrid API Key
Log in to your SendGrid account. Click on your user name on the left hand side of the UI and choose "Setup Guide" from the drop-down menu. On the "Welcome" menu, choose "Send Your First Email", and then "Integrate using our Web API or SMTP relay." Choose "Web API" as the recommended option on the next screen, as we'll be using that for this tutorial. For more information about creating API keys, see https://sendgrid.com/docs/Classroom/Send/How_Emails_Are_Sent/api_keys.html
Expand All @@ -44,7 +44,7 @@ For the rest of the tutorial, we'll be working out of the git repository we clon
```
$ cd hello-email
```
note: this assumes you cloned the git repo inside your current directory. My directory is:
note: this assumes you cloned the Git repo inside your current directory. My directory is:

```
~/projects/hello-email
Expand Down Expand Up @@ -100,7 +100,7 @@ virtualenv venv
source ./venv/bin/activate
```

Prior to being able to deploy our Python code, we'll need to install the sendgrid Python module *locally*. One of the idiosyncracies of AWS Lambda is that all library and module dependencies that aren't part of the standard library have to be included with the code/build artifact. Virtual environments do not translate to the Lambda runtime environment.
Prior to being able to deploy our Python code, we'll need to install the sendgrid Python module *locally*. One of the idiosyncracies of AWS Lambda is that all library and module dependencies that aren't part of the standard library have to be included with the code/build artifact. Virtual environments do not translate to the Lambda runtime environment.

In the root project directory, run the following command:
```
Expand Down Expand Up @@ -157,16 +157,16 @@ $ git commit -m 'hello-email app'
$ git push
```

Once the code is successfully pushed, head back to the AWS CodeStar dashboard for your project. After your commit successfully registers, an automated build and deployment process should kick off.
Once the code is successfully pushed, head back to the AWS CodeStar dashboard for your project. After your commit successfully registers, an automated build and deployment process should kick off.

One more step left before our application will work correctly. After your code has bee deployed, head to the AWS Lambda console. Click on your function name, which should start with `awscodestar-hello-email-lambda-`, or similar.

Scroll down to the "Environment Variables" section. Here we need to populate our SendGrid API key. Copy the value from the `sendgrid.env` file you created earlier, ensuring to capture the entire value. Make sure the key is titled:
Scroll down to the "Environment Variables" section. Here we need to populate our SendGrid API key. Copy the value from the `.env` file you created earlier, ensuring to capture the entire value. Make sure the key is titled:

```
SENDGRID_API_KEY
```

Now, go back to your project dashboard in CodeStar. Click on the link under "Application endpoints". After a moment, you should be greeted with JSON output indicating an email was successfully sent.
Now, go back to your project dashboard in CodeStar. Click on the link under "Application endpoints". After a moment, you should be greeted with JSON output indicating an email was successfully sent.

Congratulations, you've just used serverless technology to create an email sending app in AWS!
Congratulations, you've just used serverless technology to create an email sending app in AWS!