- AWS: Python Setup
- AWS: Python Kinesis Streams
- AWS: Python S3
When you want to work with S3 or a Kinesis Stream we first need to setup the connection. At the time of this writing I am using boto3 version 1.3.1.
Next we need to import the package.
import boto3
Next we setup the session and specify what profile we will be using.
profile = boto3.session.Session(profile_name='prod')
The profile name comes from the “credentials” file. You can set the environment variable “AWS_SHARED_CREDENTIALS_FILE” to specify what credentials file to use. You can setup the credentials file like below. You can change the “local” to anything you want. I normally use “stage”, “dev” or “prod”.
[local] aws_access_key_id=##KEY_ID## aws_secret_access_key=##SECRET_ACCESS_KEY## region=##REGION##
Next we need to setup the connection to S3. To do this we will need to use the profile we created above.
connection_s3 = profile.resource('s3')
If we want to also use a Kinesis stream then we need to setup the connection. To do this we will need the profile we created above.
connection_kinesis = profile.client('kinesis')