<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yuki0417</title>
    <description>The latest articles on DEV Community by yuki0417 (@yuki0417).</description>
    <link>https://dev.to/yuki0417</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F280161%2F60f5c71e-fbda-4923-a9f4-c6a9b5703ba3.png</url>
      <title>DEV Community: yuki0417</title>
      <link>https://dev.to/yuki0417</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yuki0417"/>
    <language>en</language>
    <item>
      <title>Easy way to connect to Amazon ElastiCache (redis) with password from Django app</title>
      <dc:creator>yuki0417</dc:creator>
      <pubDate>Tue, 26 Nov 2019 13:10:25 +0000</pubDate>
      <link>https://dev.to/yuki0417/easy-way-to-connect-to-amazon-elasticache-redis-with-password-from-django-app-40il</link>
      <guid>https://dev.to/yuki0417/easy-way-to-connect-to-amazon-elasticache-redis-with-password-from-django-app-40il</guid>
      <description>&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ElastiCache (redis) instance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;your Django app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;git&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;pip package manager&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  install redis
&lt;/h2&gt;

&lt;p&gt;install redis by below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Copy the part of django-redis-sessions in your project directory
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clone to any directory &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Clone git repository wherever you want to put.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/martinrusev/django-redis-sessions#django-redis-sessions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Copy redis_sessions to your project directory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Copy redis_sessions directory in django-redis-sessions to your project directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -r redis_sessions your_directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit session.py and your settings.py&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open below files with editor, and add the codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# session.py

    def get(self):
        ...
        elif self.connection_type == 'redis_host':
        ...
            db=settings.SESSION_REDIS_DB,
            # add below code
            SSL=True,


# settings.py

# add below code
SESSION_ENGINE = 'your_directory.redis_sessions.session'

SESSION_REDIS = {
    'host': 'your_aws_elasticache_endpoint_name',
    'port': your_port,
    'db': 0,
    'password': your_password,
    'prefix': 'session',
    'socket_timeout': 3,
    'retry_on_timeout': False
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;※ In your password setting, using encryption middleware such as django-environ, python-decouple is better.&lt;/p&gt;

&lt;p&gt;The reason why we edit session.py is to use SSL mode. By doing that, we can connect to ElastiCache by SSL tunnel mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finish! Check Connection
&lt;/h2&gt;

&lt;p&gt;Confirm by running the server, testing, or connecting to ElastiCache directly, etc.&lt;/p&gt;

&lt;p&gt;I hope I can help you to deploy your Django app to AWS!!&lt;/p&gt;

</description>
      <category>djangoredissessions</category>
      <category>elasticache</category>
      <category>aws</category>
      <category>django</category>
    </item>
  </channel>
</rss>
