<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Florent Pajot on Medium]]></title>
        <description><![CDATA[Stories by Florent Pajot on Medium]]></description>
        <link>https://medium.com/@florentpajot?source=rss-1429ccab386d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ch47xijOyfkWx_dreEOa-w.jpeg</url>
            <title>Stories by Florent Pajot on Medium</title>
            <link>https://medium.com/@florentpajot?source=rss-1429ccab386d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:29:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@florentpajot/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[5 Key Soft Skills to Elevate Your Data Science Game]]></title>
            <link>https://medium.com/data-science/5-key-soft-skills-to-elevate-your-data-science-game-1a4451f6884b?source=rss-1429ccab386d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a4451f6884b</guid>
            <category><![CDATA[career-development]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[big-data-career]]></category>
            <category><![CDATA[soft-skills]]></category>
            <dc:creator><![CDATA[Florent Pajot]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 17:18:00 GMT</pubDate>
            <atom:updated>2024-04-05T17:18:00.174Z</atom:updated>
            <content:encoded><![CDATA[<h4>Top soft skills that should be highly valued by data scientists to distinguish themselves from the crowd</h4><p>In this story, I’ll share with you my top 5 soft skills that should be highly valued by Data Scientists to distinguish themselves from the crowd. These observations are based on my experiences over the past decade, working with and managing Data Scientists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hZThomiT1R4RNZb9" /><figcaption>Photo by <a href="https://unsplash.com/@garybpt?utm_source=medium&amp;utm_medium=referral">Gary Butterfield</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>1. Curiosity</h3><p>I won’t catch you off guard with this one (or the next), yet curiosity remains a key characteristic for Data Scientists (and numerous other professions).</p><h4>Keep learning</h4><p>Data Scientists should value curiosity a lot because curiosity fosters continuous learning and adaptation in the rapidly evolving field of data science.</p><p>Given the constant influx of innovations from research papers or conferences, a curious mindset encourages Data Scientists to stay abreast of emerging trends, embrace new tools, and refine their skills.</p><p>I’ve experienced moments in my career where I would focus on a topic for months, lowering my head and forgetting about everything else. At some point, my curiosity brings me back to earth and urges me to open my eyes and look for what happened in the field during that span. Without it, I would get stuck and become outdated.</p><h4>Think outside the box</h4><p>Also, curiosity is a source of creativity in problem-solving.</p><p>Data Science often presents intricate challenges that demand innovative approaches and is also often about finding new ways to apply old and proven approaches to new domains in ways that have not been tried before.</p><p>Thus, curious minds are more likely to think outside the box, widen their options, and try new things out. That’s all you need to solve problems!</p><p>Creativity doesn’t find its lone source in curiosity. For example, I think that a team composed of people with diverse backgrounds has more chance to foster creativity. So if you are a manager, think about hiring people very different from you or your colleagues, be curious about unorthodox career paths, and you might find gems.</p><h4>How to bolster your curiosity?</h4><ol><li>Read</li></ol><p>You should read more blogs and more books (or whatever other formats you like to read/listen to). You should pick topics you’re not experienced with, topics going beyond what you usually read. If you have a scientific background, read about business, communication, decision-making, etc.</p><p>I like reading about topics I’m passionate about like Basketball, Data Science, or Data Engineering. However, I also try reading more about software engineering, marketing, entrepreneurship, biology, personal finance, etc.</p><p>2. Step outside your comfort zone</p><p>Seize any opportunity to leave your comfort zone and learn new things. If you adopt a position where everything is of interest, and everyone is worth listening to, you’ll widen your world and start questioning yourself about things outside your domain of expertise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-RUX8mXQsBbwGBQF" /><figcaption>Photo by <a href="https://unsplash.com/@meymigrou?utm_source=medium&amp;utm_medium=referral">Panos Sakalakis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>2. Communication</h3><p>In any profession, you’ve likely encountered the challenges of collaborating with someone who struggles with effective communication. This issue becomes particularly pronounced in the realm of Data Science, where adeptly conveying technical concepts presents a formidable challenge.</p><h4>Adapt to your audience</h4><p>Data Scientists are often at the interface of several teams, working with various stakeholders, and people with diverse backgrounds. So bridging the knowledge gap, and ensuring everybody has a common understanding of what is said is important.</p><p>Without clear communication, collaborating becomes rapidly impossible and might jeopardize a project, a team, or your job.</p><p>In my previous experience, I’ve always been impressed by people able to express their current work without using any technical concept. For me, it tells a lot about how much one person is in control of the subject and gets an overview of it before talking.</p><h4>Communicating results efficiently</h4><p>Even if just 1% of your project time is dedicated to communicating results, this seemingly small fraction often holds 99% of the value to be conveyed.</p><p>Regrettably, I’ve noticed that many junior Data Scientists devote weeks to perfecting their technical methodologies or data analyses, only to stumble when it comes to delivering impactful insights due to inadequate communication.</p><h4>How to improve your communication?</h4><ol><li>Practice</li></ol><p>You should consider every opportunity to interact with people as a chance to practice and refine your communication skills.</p><p>For example, if you have daily meetings, prepare them for a few minutes and make sure to deliver clear communication to your audience.</p><p>Whenever I have an “important” meeting, I take 5 minutes to prepare. My recipe is the following:</p><ul><li>take 1 minute for a zygomatic warm-up (it helps to improve pronunciation) -&gt; <a href="https://preply.com/en/blog/english-pronunciation-practice/">https://preply.com/en/blog/english-pronunciation-practice/</a></li><li>define my objectives</li><li>identify what my audience&#39;s interest in listening to me</li><li>write down key topics or a structured summary of my intervention</li></ul><p>Always make the hypothesis that they don’t know anything about what you’re doing, and help them close the knowledge gap so that they feel comfortable with what you are saying.</p><p>Also, ask them for feedback: do you remember what is my primary objective today? Was it clear enough?</p><p>Resources:</p><ul><li><a href="https://hbr.org/2023/06/how-to-give-and-receive-critical-feedback">https://hbr.org/2023/06/how-to-give-and-receive-critical-feedback</a></li><li><a href="https://kimmalonescott.medium.com/asking-for-feedback-how-to-solicit-radical-candor-823dab2860c0">https://kimmalonescott.medium.com/asking-for-feedback-how-to-solicit-radical-candor-823dab2860c0</a></li></ul><p>2. Read</p><p>Read books about communication! I highly recommend beginning with “Made To Stick” by Chip and Dan Heath, a book that offers a methodology for making your ideas more memorable and impactful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6mipGV-vuHVQWlEK" /><figcaption>Photo by <a href="https://unsplash.com/@seemamiah?utm_source=medium&amp;utm_medium=referral">Seema Miah</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You can also find interesting resources on the internet for free like <a href="https://online.hbs.edu/blog/post/communication-techniques">https://online.hbs.edu/blog/post/communication-techniques</a></p><h3>3. Scientific Mindset</h3><p>It is easy to forget about the “scientist” part of the “data scientist” role name, but it is very important to remember that a Data Scientist must apply a scientific approach to solving problems using data.</p><p>Scientific rigor forms the bedrock of Data Science, ensuring that analyses are robust, reliable, and reproducible. Applying scientific rigor mainly refers to adhering to a rigorous methodology, and critically evaluating findings.</p><p>You can be a great software engineer without applying any scientific methodology. But you won’t be a good Data Scientist without it.</p><p>In my opinion, this is not an option. Even if you’re not a research scientist, exercising scientific rigor is vital to mitigate the risk of erroneous conclusions. That’s why, whenever I discuss experiments and results with a colleague, I tend to value the scientific approach over the results in the first phase.</p><h4>Tips to embrace a higher level of scientific rigor</h4><ol><li>Problem definition</li></ol><p>It’s easier said than done. But, if you are solving the wrong problem, you won’t go anywhere and lose your time. Unfortunately, most people jump on the first available version of a problem because they prefer writing code. So, the solution is simple, invest more time in defining the problem, discussing desired outcomes with stakeholders, and setting proper starting hypotheses/constraints.</p><p>2. Statistics</p><p>Statistics is one of the 3 pillars of a Data Scientist&#39;s hard skills. And, any scientific approach needs a fair use of statistical tools. For example, statistical tests will help you check for feature correlation or data distribution. So, if you’re not comfortable with it, think about leveling up your statistical arsenal.</p><p>You can start right now on Medium: <a href="https://towardsdatascience.com/ultimate-guide-to-statistics-for-data-science-a3d8f1fd69a7">https://towardsdatascience.com/ultimate-guide-to-statistics-for-data-science-a3d8f1fd69a7</a></p><p>I recommend also this comprehensive book: <a href="https://www.oreilly.com/library/view/practical-statistics-for/9781492072935/">https://www.oreilly.com/library/view/practical-statistics-for/9781492072935/</a></p><p>3. Tools</p><p>People tend to try multiple things at once to save time. But going step by step, assessing one thing at a time is mandatory to make sure you understand what’s going on and draw the right conclusions.</p><p>Using the appropriate tool can significantly facilitate the process. This is precisely the function of “Experiment tracking” tools, which are increasingly used within the Data Science domain.</p><p>For personal projects like Kaggle competitions, I like using <a href="https://dvc.org/doc/api-reference">DVC</a> which introduced experiment tracking features a few years ago. However, much more advanced tools are available on the market like <a href="https://mlflow.org/docs/latest/introduction/index.html">MLFlow</a> or <a href="https://neptune.ai/">Neptune.ai</a>.</p><p>You can find a comprehensive comparison of experiment-tracking tools here: <a href="https://towardsdatascience.com/a-comprehensive-comparison-of-ml-experiment-tracking-tools-9f0192543feb">https://towardsdatascience.com/a-comprehensive-comparison-of-ml-experiment-tracking-tools-9f0192543feb</a></p><p>But, you don’t need a sophisticated tool to take notes of your thoughts, questions, and experiments. So I’d recommend at least taking the first step by just writing down things on a notepad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zs2f9oxd0_yHXxdT" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>4. Integrity</h3><p>As any Data Scientist knows too well, a data analysis can vary significantly based on the narrative one wishes to convey to his audience.</p><h4>Is he lying with data?</h4><p>There is no denying that conclusions drawn from a dataset are inherently influenced by the perspective and intentions of the presenter. This simple fact underscores the importance of integrity.</p><p>Resources:</p><ul><li>How To Lie With Statistics by Darrell Huff</li><li><a href="https://towardsdatascience.com/lessons-from-how-to-lie-with-statistics-57060c0d2f19">https://towardsdatascience.com/lessons-from-how-to-lie-with-statistics-57060c0d2f19</a></li></ul><p>With great power comes great responsibility. But, this is not the only reason why integrity is important to me.</p><h4>Challenge model bias</h4><p>Bias in models is also a now well-advertised issue every Data Science practitioner should care about.</p><p>Tackling this problem is a difficult task but everybody should feel concerned because of potential business impacts, and more importantly, because of the potential societal impact one biased model can have.</p><p>Interesting resources on the topic:</p><ul><li><a href="https://developers.google.com/machine-learning/crash-course/fairness/video-lecture">https://developers.google.com/machine-learning/crash-course/fairness/video-lecture</a></li><li><a href="https://pair-code.github.io/what-if-tool/">https://pair-code.github.io/what-if-tool/</a></li></ul><p>If you’re an AWS user like me, <a href="https://aws.amazon.com/sagemaker/clarify/">Sagemaker Clarify</a> provides numerous analyses for bias detection.</p><p>If you are interested in fairness for Deep Learning, take an attentive look at <a href="https://www.deel.ai/bias/">DEEL lab publications</a> on the subject and their open-source solutions like <a href="https://github.com/deel-ai/influenciae">Influencia</a>.</p><h4>Environmental Impact</h4><p>Another ethical aspect of Data Science is its environmental impact which is often downplayed due to its complexity in measurement and comprehension.</p><p>I guess the research in this area is expanding, and I would appreciate hearing from you if you have materials to share with me on the subject.</p><p>It is imperative for Data Scientists to actively assess and mitigate their environmental impact. For instance, they must question whether processing an extensive quantity of data is essential to achieve the desired business objectives.</p><p>Additionally, they should explore methods to minimize the environmental repercussions of their models. Then, sharing results and perspectives with stakeholders will broaden awareness of the environmental implications inherent in data-driven decision-making.</p><p>There are many more dimensions to this problem and I’ll think about it for a future story.</p><p>Interesting resources:</p><ul><li><a href="https://www.oecd.org/publications/measuring-the-environmental-impacts-of-artificial-intelligence-compute-and-applications-7babf571-en.htm">https://www.oecd.org/publications/measuring-the-environmental-impacts-of-artificial-intelligence-compute-and-applications-7babf571-en.htm</a></li><li><a href="https://www.nature.com/articles/s42256-020-0219-9">https://www.nature.com/articles/s42256-020-0219-9</a></li><li>Editors like AWS may provide tools like <a href="https://aws.amazon.com/aws-cost-management/aws-customer-carbon-footprint-tool/">https://aws.amazon.com/aws-cost-management/aws-customer-carbon-footprint-tool/</a></li></ul><p>If you want to start thinking about your code carbon footprint:</p><ul><li><a href="https://mlco2.github.io/codecarbon/">https://mlco2.github.io/codecarbon/</a></li><li>understanding where your code is inefficient is also a good start: <a href="https://pyinstrument.readthedocs.io/en/latest/">https://pyinstrument.readthedocs.io/en/latest/</a></li></ul><h4>How do you keep your integrity?</h4><p>Integrity is about being honest with yourself, consistent in your values, and acting according to your principles. So, the first thing is questioning yourself about your core values and the best way to incarnate them at work daily.</p><p>Then, resist external pressure and stay true to yourself. Also, don’t ignore the ethical challenges of the domain. They are an increasing concern for society, and we are responsible for providing solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AjQkmri8t0nEv4Sc" /><figcaption>Photo by <a href="https://unsplash.com/@javaistan?utm_source=medium&amp;utm_medium=referral">Afif Ramdhasuma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>5. Being value-centric</h3><p>All Data Scientists just love exploring data and building models. That’s why Kaggle is so popular. As a professional, it is easy to be trapped by infinite data exploration, unbounded experiments, or model optimizations.</p><p>Value-centricity refers to an approach or mindset that places a strong emphasis on delivering value as the primary objective in decision-making, problem-solving, and overall strategy.</p><p>So, in the context of Data Science, being value-centric means you’ll have to keep your focus and employ your skills to create value rather than losing your time with the technical issues you’d like to solve to reach an optimal solution.</p><p>Once again, the best Data Scientists I worked with are exploring data on purpose, asking and answering the questions that will help them solve the right problem. Then, they conduct the minimum required experiments to draw a solution and build an MVP. They quickly go to production to see what happens, and iterate.</p><p>This path is made of numerous tradeoffs between optimizing things and adding incremental value to the end user.</p><h4>How to be focused on value?</h4><p>One hard thing about being value-centric is recognizing that even if you’re not building a comprehensive data product by yourself, you’re building a piece of it, so you must conform to a product mindset and focus on the value you’ll ultimately generate for an end user.</p><p>Your decisions should always assess the time it will take to do something compared to the value it provides in terms of product. Some things are important but can be postponed for future iterations, other things are not interesting enough to be done.</p><p>When building a Data Science model, it is often possible to quickly assess if a model would yield good enough value depending on the expected performance and how it will impact the business.</p><p>For example, if you are not familiar with building custom scoring functions for evaluating your model based on nontechnical metrics, take a look at this: <a href="https://towardsdatascience.com/calculating-the-business-value-of-a-data-science-project-3b282de9be3c">https://towardsdatascience.com/calculating-the-business-value-of-a-data-science-project-3b282de9be3c</a></p><p>At some point, you may also face the opportunity to improve model performance. This is the right time to understand what kind of improvements will be valuable. Is increasing your F1 score by 0.01 worth it compared to the effort you need to provide? Does it require collecting 100k new labeled data points?</p><p>As product owners and other software engineers might not understand all the technical aspects of developing a model, it is your responsibility to make these decisions.</p><p>Other interesting resources:</p><ul><li>The work ethic concept captures the ideas of value and ownership: <a href="https://hbr.org/2022/09/how-to-develop-a-strong-work-ethic">https://hbr.org/2022/09/how-to-develop-a-strong-work-ethic</a></li></ul><h3>Conclusions</h3><p>To become a better Data Scientist, you should focus on developing your curiosity, communication, integrity, scientific mindset, and value-centricity.</p><p>Most of the time, I would recommend reading books, but there are also numerous other valuable materials such as online courses and blog articles. Some of these skills can only be developed by being confronted with reality. Thus, be aware and prepared for the opportunities you’ll face.</p><p>If you would like to receive notifications for my upcoming posts regarding Data Science and more, <a href="https://medium.com/@florentpajot/subscribe">please subscribe here</a> or follow me.</p><p><em>Did you know you can clap multiple times?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a4451f6884b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/5-key-soft-skills-to-elevate-your-data-science-game-1a4451f6884b">5 Key Soft Skills to Elevate Your Data Science Game</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set up a Pypi mirror in an AWS private environment with Terraform]]></title>
            <link>https://medium.com/data-science/set-up-a-pypi-mirror-in-an-aws-private-environment-with-terraform-f0fcc1b67cc0?source=rss-1429ccab386d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0fcc1b67cc0</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Florent Pajot]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 11:49:48 GMT</pubDate>
            <atom:updated>2024-03-14T14:45:40.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up a Pypi mirror in an AWS private environment with Terraform</h3><p>How do you install a Python package in your environment if you don’t have any internet access? I recently came across this issue when creating an AWS Sagemaker Studio environment for my team on AWS.</p><h4>Building an AWS private environment for Sagemaker</h4><p>For this particular project, I set up Sagemaker in VPC Only mode with the constraint of keeping the architecture private, which means creating a VPC and private subnets, but no access to the internet.</p><p>So all network communications, including application communication with AWS APIs, must go through VPC Endpoint interfaces. This allows for keeping connection secured as data sent and received will never go through the internet using the AWS network backbone instead.</p><p>It is particularly suited for limiting exposure to security risks, more particularly when you’re processing personal information, or must comply with some security standards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBLSUWLFAkqc22VW" /><figcaption>Photo by <a href="https://unsplash.com/@nadir_syzygy?utm_source=medium&amp;utm_medium=referral">Nadir sYzYgY</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Accessing the Pypi package repository from AWS Sagemaker</h4><p>In my team, Data Scientists use Python as a primary language and sometimes need Python packages that are not provided in <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/docker-containers-prebuilt.html">Sagemaker’s pre-built Python images</a>, so I’ll focus on this use case. Fortunately, the solution is also working for other languages and repositories like npm.</p><p>Your users will typically try to install whatever package they need via pip command. But, as no internet access is allowed, this command will fail because pip won’t be able to contact Pypi.org servers.</p><p><strong>Opening internet</strong></p><p>One option is to open access to the internet and allow outbound HTTP connections to Fastly CDN IPs used by Pypi.org servers. But, this is not viable in our case as we don’t want any internet connection in the architecture.</p><p><strong>Using a dedicated Pypi server</strong></p><p><a href="https://aws.amazon.com/fr/blogs/machine-learning/hosting-a-private-pypi-server-for-amazon-sagemaker-studio-notebooks-in-a-vpc/">AWS blog also provides an example of using a Python package named Bandersnatch</a>. This article describes how to set up a server, acting like a bastion host, which will mirror Pypi and will be accessible only to your private subnets.</p><p>This is not a viable option as you’ve to know in advance which Python packages you need to provide, and you’ll somehow have to create public subnets and give the Pypi server mirror access to the internet.</p><p><strong>Using AWS Cordeartifact</strong></p><p>This is ultimately the solution I came up with and which works in my case.</p><p><a href="https://aws.amazon.com/fr/codeartifact/">AWS Codeartifact</a> is the artifact management solution provided by AWS. It is compatible with other AWS services like AWS Service Catalog to control access to resources within an organization.</p><p>To use it, you’ll have to create a “domain” which serves as an umbrella to manage access and apply policies across your organization. Then, you’ll have to create a repository that will serve your artifacts to your different applications.</p><p>Also, one repository can have upstream repositories. So, if a Python package is not available in the target repository, the demand will be transmitted to the upstream repository to be fulfilled.</p><p>More precisely, this workflow takes into account package versions. Official documentation provides a detailed workflow:</p><blockquote>If my_repo contains the requested package version, it is returned to the client.</blockquote><blockquote>If my_repo does not contain the requested package version, CodeArtifact looks for it in my_repo&#39;s upstream repositories. If the package version is found, a reference to it is copied to my_repo, and the package version is returned to the client.</blockquote><blockquote>If neither my_repo nor its upstream repositories contain the package version, an HTTP 404 Not Found response is returned to the client.</blockquote><p>Cool right? It will even cache the package version for future requests.</p><p>This is precisely the strategy we are going to use, as AWS Codeartifact allows us to define a repository that has an external connection like Pypi as an upstream repository.</p><h4>Creating AWS Codeartifact resources with Terraform</h4><p>As AWS Codeartifact is an AWS service, you can easily create a VPC endpoint in your environment VPC to connect to it.</p><p>Note: I’m using Terraform v1.6.4 and aws provider v5.38.0</p><pre>locals {<br>  region = &quot;us-east-1&quot;<br>}<br><br>resource &quot;aws_security_group&quot; &quot;vpce_sg&quot; {<br>  name        = &quot;AllowTLS&quot;<br>  description = &quot;Allow TLS inbound traffic and all outbound traffic&quot;<br>  vpc_id      = aws_vpc.your_vpc.id<br><br>  tags = {<br>    Name = &quot;allow_tls_for_vpce&quot;<br>  }<br>}<br><br>resource &quot;aws_vpc_security_group_ingress_rule&quot; &quot;allow_tls_ipv4&quot; {<br>  security_group_id = aws_security_group.allow_tls.id<br>  cidr_ipv4         = aws_vpc.your_vpc.cidr_block<br>  from_port         = 443<br>  ip_protocol       = &quot;tcp&quot;<br>  to_port           = 443<br>}<br><br>data &quot;aws_iam_policy_document&quot; &quot;codeartifact_vpce_base_policy&quot; {<br>  statement {<br>    sid    = &quot;EnableRoles&quot;<br>    effect = &quot;Allow&quot;<br>    actions = [<br>      &quot;codeartifact:GetAuthorizationToken&quot;,<br>      &quot;codeartifact:GetRepositoryEndpoint&quot;,<br>      &quot;codeartifact:ReadFromRepository&quot;,<br>      &quot;sts:GetServiceBearerToken&quot;<br>    ]<br>    resources = [<br>      &quot;*&quot;,<br>    ]<br>    principals {<br>      type = &quot;AWS&quot;<br>      identifiers = [<br>        aws_iam_role.your_sagemaker_execution_role.arn<br>      ]<br>    }<br>  }<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;codeartifact_api_vpce&quot; {<br>  vpc_id            = aws_vpc.your_vpc.id<br>  service_name      = &quot;com.amazonaws.${local.region}.codeartifact.api&quot;<br>  vpc_endpoint_type = &quot;Interface&quot;<br>  subnet_ids        = aws_subnets.your_private_subnets.ids<br><br>  security_group_ids = [<br>    aws_security_group.vpce_sg.id,<br>  ]<br><br>  private_dns_enabled = true<br>  policy              = data.aws_iam_policy_document.codeartifact_vpce_base_policy.json<br>  tags = { Name = &quot;codeartifact-api-vpc-endpoint&quot; }<br>}</pre><p>Then, you’ll have to create the different resources needed for Codeartifact to handle your requests for new Python packages by mirroring Pypi: a domain, a Pypi repository with an external connection, and a repository that defines Pypi as an upstream repository.</p><pre>resource &quot;aws_codeartifact_domain&quot; &quot;my_domain&quot; {<br>  domain = &quot;my-domain&quot;<br><br>  encryption_key = &quot;&quot;<br><br>  tags = { Name = &quot;my-codeartifact-domain&quot; }<br>}<br><br><br>resource &quot;aws_codeartifact_repository&quot; &quot;public_pypi&quot; {<br>  repository = &quot;pypi-store&quot;<br>  domain     = aws_codeartifact_domain.my_domain.domain<br><br>  external_connections {<br>    external_connection_name = &quot;public:pypi&quot;<br>  }<br><br>  tags = { Name = &quot;pypi-store-repository&quot; }<br>}<br><br>resource &quot;aws_codeartifact_repository&quot; &quot;my_repository&quot; {<br>  repository = &quot;my_repository&quot;<br>  domain     = aws_codeartifact_domain.my_domain.domain<br><br>  upstream {<br>    repository_name = aws_codeartifact_repository.public_pypi.repository<br>  }<br><br>  tags = { Name = &quot;my-codeartifact-repository&quot; }<br>}<br><br>data &quot;aws_iam_policy_document&quot; &quot;my_repository_policy_document&quot; {<br>  statement {<br>    effect = &quot;Allow&quot;<br><br>    principals {<br>      type        = &quot;AWS&quot;<br>      identifiers = [aws_iam_role.your_sagemaker_execution_role.arn]<br>    }<br><br>    actions   = [&quot;codeartifact:ReadFromRepository&quot;]<br>    resources = [aws_codeartifact_repository.my_repository.arn]<br>  }<br>}<br><br>resource &quot;aws_codeartifact_repository_permissions_policy&quot; &quot;my_repository_policy&quot; {<br>  repository      = aws_codeartifact_repository.my_repository.repository<br>  domain          = aws_codeartifact_domain.my_domain.domain<br>  policy_document = data.aws_iam_policy_document.my_repository_policy_document.json<br>}</pre><p>Here it is! You can now set up a Pypi mirror for your private environment easily.</p><p>To make things usable, you’ll also have to tell pip commands to direct requests to a specific index. Fortunately, AWS created an API to do the heavy lifting for you. Just add this to your code to make it work:</p><pre>aws codeartifact login --tool pip --repository $CODE_ARTIFACT_REPOSITOR_ARN --domain $CODE_ARTIFACT_DOMAIN_ID --domain-owner $ACCOUNT_ID --region $REGION</pre><p>Last but not least, add a VPC Endpoint for AWS Codeartifact in your VPC.</p><pre>data &quot;aws_iam_policy_document&quot; &quot;codeartifact_vpce_base_policy&quot; {<br>  statement {<br>    sid    = &quot;EnableRoles&quot;<br>    effect = &quot;Allow&quot;<br>    actions = [<br>      &quot;codeartifact:GetAuthorizationToken&quot;,<br>      &quot;codeartifact:GetRepositoryEndpoint&quot;,<br>      &quot;codeartifact:ReadFromRepository&quot;,<br>      &quot;sts:GetServiceBearerToken&quot;<br>    ]<br>    resources = [<br>      &quot;*&quot;,<br>    ]<br>    principals {<br>      type = &quot;AWS&quot;<br>      identifiers = [<br>        aws_iam_role.your_sagemaker_execution_role.arn<br>      ]<br>    }<br>  }<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;codeartifact_api_vpce&quot; {<br>  vpc_id            = aws_vpc.your_vpc.id<br>  service_name      = &quot;com.amazonaws.${local.region}.codeartifact.api&quot;<br>  vpc_endpoint_type = &quot;Interface&quot;<br>  subnet_ids        = aws_subnets.your_private_subnets.ids<br><br>  security_group_ids = [<br>    aws_security_group.vpce_sg.id,<br>  ]<br><br>  private_dns_enabled = true<br>  policy              = data.aws_iam_policy_document.codeartifact_vpce_base_policy.json<br>  tags = { Name = &quot;codeartifact-api-vpc-endpoint&quot; }<br>}</pre><p>If you would like to receive notifications for my upcoming posts regarding AWS and more, <a href="https://medium.com/@florentpajot/subscribe">please subscribe here</a>.</p><p><em>Did you know you can clap multiple times?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0fcc1b67cc0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/set-up-a-pypi-mirror-in-an-aws-private-environment-with-terraform-f0fcc1b67cc0">Set up a Pypi mirror in an AWS private environment with Terraform</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>