<?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[Lazy Tech Leader Series - Medium]]></title>
        <description><![CDATA[Short Guideline for Tech Leader to think structurally - Medium]]></description>
        <link>https://medium.com/lazy-tech-leader-series?source=rss----eb2eaf6dbfe---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Lazy Tech Leader Series - Medium</title>
            <link>https://medium.com/lazy-tech-leader-series?source=rss----eb2eaf6dbfe---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:54:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/lazy-tech-leader-series" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to ensure your Internet coverage in big house]]></title>
            <link>https://medium.com/lazy-tech-leader-series/how-to-ensure-your-internet-coverage-in-big-house-d9e587499893?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/d9e587499893</guid>
            <category><![CDATA[coaxial-cable]]></category>
            <category><![CDATA[wifi-extender]]></category>
            <category><![CDATA[landed-house]]></category>
            <category><![CDATA[powerline]]></category>
            <category><![CDATA[internet-coverage]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 11:51:54 GMT</pubDate>
            <atom:updated>2021-10-13T02:24:47.147Z</atom:updated>
            <content:encoded><![CDATA[<p>You bought your dreamed house. It is landed house with multi-storey. A bit old, but have enough space. Everything looks great, except that you don’t have enough internet coverage. In some area, the Wi-Fi signal is extremely weak, and you can barely watch video.</p><p>The most easiest way to think is to setup physical internet cable to connect to every part of your house. However, the cable setup outside the wall look ugly. If you hide it inside the wall, contractor needs to destroy your wall, patch up and then paint. It costs a lot to do so too. Here, let me share some alternative solutions:</p><h3>Use Coax Line to Transfer Internet Signals</h3><p>In old house like 10 years ago, coax line setup is a standard. Coax Line point on your wall look like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*UcwbkK07yvJAFeH2.jpg" /></figure><p>Luckily you may have this interfaces in all rooms, then coax line solution would be best fit for your purpose. It is so far the most stable solution other than physical internet cable. If you have 1G board band internet, the speed is roughly 800M+, which is pretty good.</p><p>What you need to do is for each coax point, you buy one MoCA adapter. This adapter can covert internet signal to coax signal and vice visa. You can then connect MoCA adapter to router to have Wi-Fi Coverage too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*z8tDWDIMCeBb3CYY.jpg" /></figure><p>I used Motolora MoCA adapter, bought from Amazon. The quality is pretty good.</p><p>Please remember that you need to connect coax line in your house together. Normally you should see connector similar below located in your main switch box. This was used to send TV signal, in the old days, from TV provider to your house. Now what you need to do is to change the input and output of this connector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*2pJeAlFXIEgXWPPkrsYx7Q.png" /></figure><p>let us take an example that your internet router is located at level 1, and you need to send the signal to level 2 and 3. The middle one is the input, and outsider are the output. So you need to connect Level 1 coax line to the input, and level 2/3 on the output. In some cases you don’t know which line is level1 and which one is level 2, you can connect each line to MoCA adapter to test the signal out. As long as all the indicator light is flashing in your MoCA adapter, that means connection is established.</p><p>After you setup the connection successfully, congratulations!! You can enjoy the stable and reliable internet now.</p><h3>Use Power Line to Transfer Internet Signals</h3><p>If you don’t have coax line available in the house, you can try to use Power Line, which is used to carry electricity of your house. The earth line of the Power Line can be used to transfer internet signal too. But the performance varies from place to place. In my case, I could only manage to get 50M~300M out of 1G board band in different timing of the day. It depends on whether your neighbor use the same kind of setup or not. Also depends on the age of your powerline in your house.</p><p>To setup Powerline is quite simple, you can plug in the Powerline Adapter into Power Switch with one of them connects to internet router. It has embedded router by default, so you can enjoy Wi-Fi when you plug into the switch. It can be moved freely into any part of your room as long as there is a power switch.</p><p>With 50M speed, you can enjoy video quite well. It maybe a bit slow if you are playing games.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*BDxOjN5Qy-YC0ysE.jpg" /></figure><p>I hope this give you some good idea about setting up Ethernet in your home, and save the money for renovation. If you like this article, please help clap. Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9e587499893" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/how-to-ensure-your-internet-coverage-in-big-house-d9e587499893">How to ensure your Internet coverage in big house</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLB In IP Scarce Situation]]></title>
            <link>https://medium.com/lazy-tech-leader-series/nlb-in-ip-scarce-situation-b235e692cf1f?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/b235e692cf1f</guid>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[nlb]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 07:25:34 GMT</pubDate>
            <atom:updated>2022-11-11T02:03:53.512Z</atom:updated>
            <content:encoded><![CDATA[<p>NLB stands for <a href="https://aws.amazon.com/elasticloadbalancing/network-load-balancer/">Network Load Balancer</a>. It is one of the most commonly used load balancer in AWS.</p><p>However, whenever we provision NLB, normally it requires 8 free IPs. In certain cases, you can reduce the IP requirement.</p><h4>Internal Network Load Balancer</h4><p>According to <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-network-load-balancer.html">AWS documentation</a>, For internet-facing load balancer (scheme = external), the subnets that you specify must have at least 8 available IP addresses. For internal load balancers (scheme = internal), this is only required if you let AWS select a private IPv4 address from the subnet.</p><h4>Cross-Zone Load Balancing</h4><p>NLB can now distribute requires regardless of Availability Zone with the support of cross-zone load balancing. This allows NLB to route traffics to applications that are deployed across multiple Availability Zone.</p><p>This is an unique feature that ALB doesn’t have. So if you use NLB, in IP scarce situation, for internal NLB, you can manage to use only one IP for all AZs in one region.</p><p>Please use this feature <strong>with caution,</strong> because if you only have NLB in one subnets. It becomes a single point of failure, which might not be suitable for high resilience.</p><h3>Implementation Samples</h3><h4>Terraform</h4><pre>data &quot;aws_subnet_ids&quot; &quot;example1&quot; {<br>  vpc_id = var.vpc_id<br><br>  tags = {<br>    Tier = &quot;Public&quot;<br>  }<br>}<br><br>resource &quot;aws_lb&quot; &quot;this&quot; {<br>  name               = &quot;basic-load-balancer&quot;<br>  load_balancer_type = &quot;network&quot;<br><br>  // enable_cross_zone_load_balancing = true //enable it if you just want to be in one subnet<br>  <br>  subnet_mapping {<br>     subnet_id = data.aws_subnet_ids.example1.ids[0]<br>     allocation_id = &quot;10.0.1.15&quot;  //change this to your private ip<br>  }<br>  <br>  subnet_mapping { //you can have multiple if you want it to be in multiple subnets<br>     subnet_id = data.aws_subnet_ids.example1.ids[0]<br>     allocation_id = &quot;10.0.2.15&quot;  //change this to your private ip<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b235e692cf1f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/nlb-in-ip-scarce-situation-b235e692cf1f">NLB In IP Scarce Situation</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to check access on my Kubernetes Namespace on EKS]]></title>
            <link>https://medium.com/lazy-tech-leader-series/how-to-check-access-on-my-kubernetes-namespace-on-eks-5ecfeca094ad?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/5ecfeca094ad</guid>
            <category><![CDATA[auth]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[rbac]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[aws-eks]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 03:08:17 GMT</pubDate>
            <atom:updated>2021-09-21T02:14:21.758Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I provisioned my Kubernetes cluster, however I found I cannot create deployments in my namespace, something must go wrong here:</p><pre>&gt; kubectl auth can-i create deployments --namespace mynamespace<br>no</pre><p>However, there is no clear guidance in Kubernetes documents on how to investigate. Here are the steps I did to figure out:</p><h3>Step 1 Describe your namespace</h3><pre>&gt;kubectl describe namespace mynamespace<br>Name: mynamespace<br>labels: core.eks/namespace=false<br>        core.eks/rbac-processed=true<br>Annotations: core.eks/owner: User:user:[userId]-[Domain].[AD link]<br>             user.eks/users: User:user:[userId]-[Domain].[AD link]<br>             user.eks/managers: User:user:[userId]-[Domain].[AD link]<br>Status: Active<br>No resource quota.<br>No LimitRange resource.</pre><p>Here you can figure out who is the owner, who is the users and who is the mangers. How do I know each of those groups contains what kind of permissions?</p><h3>Step 2 Describe your role</h3><pre>&gt;kubectl describe clusterrole<br>Name: Namespace-mynamespace-app-Manager-Role<br>Labels: core.eks/rbac-processed=true<br>Annotations: core.eks/owner: system:masters<br>             core.eks/owner-group-resource: namespaces<br>             core.eks/owner-resource-name: mynamespace<br>             core.eks/owner-resource-version: v1<br>             core.eks/rbac-processed-timestamp: YYYY-MM-DDThh:mm:ssZ<br>PolicyRule:<br>Resources        Non-Resource URLS  Resource Names  Verbs<br>---------        -----------------  --------------  -----<br>namespace/status []                 [mynamespace]   [create ......]<br>namespace        []                 [mynamespace]   [delete patch..]</pre><p>Here you can see the owner is mapped to system:masters, so what is exactly it means?</p><h3>Step 3 Check the mapped IAM Role</h3><pre>&gt;kubctl describe configmap -n kube-system aws-auth<br>Name:        aws-auth<br>Namespace:   kube-system<br>Labes:       &lt;none&gt;<br>Annotations: &lt;none&gt;</pre><pre>Data<br>====<br>mapRoles:<br>------<br>- &quot;groups&quot;:<br>  - &quot;system:masters&quot;<br>  &quot;rolearn&quot;: &quot;arn:aws:iam::[aws-account]:role/core-breakglass-main&quot;<br>  &quot;username&quot;: &quot;user:{{SessionName}}&quot;<br>.....</pre><p>kube-system is one of the default namespace created by EKS, and it is used to map Kubernetes Group with AWS IAM ARN. I will stop here, and I think you can check on your aws console to see what are the permission allowed by this core-breakglass-main.</p><p>So back to my questions, the reason why I cannot create resource in my account is due to the mistake that I configured the owner name to be the wrong person. But this investigation lead me to understand how EKS underlying permission works. I hope you enjoyed it, and thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ecfeca094ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/how-to-check-access-on-my-kubernetes-namespace-on-eks-5ecfeca094ad">How to check access on my Kubernetes Namespace on EKS</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Service Account in EKS]]></title>
            <link>https://medium.com/lazy-tech-leader-series/how-to-use-service-account-in-eks-cf4fb5926147?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/cf4fb5926147</guid>
            <category><![CDATA[rbac-access-control]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 03:07:56 GMT</pubDate>
            <atom:updated>2021-09-22T11:24:22.833Z</atom:updated>
            <content:encoded><![CDATA[<p>It is a common problem that your application running on EKS wants to access S3 or other AWS service. However, you may have two types of microservices running, being A and B. Let us assume that A is supposed to access S3, and B is supposed to access RDS. But neither you want A to access RDS, or B to access S3. Plus you don’t want to handle all the difficulties on the code level to assume role. Using service account in Kubernetes is the best way to solve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*yhGOVGLKbQul0-Jr-bEg6w.png" /></figure><h3>Create Service Account</h3><p>Compare to normal Kubernetes, AWS EKS use metadata annotations part to map to the aws ARN.</p><pre>apiVersion: v1 <br>kind: ServiceAccount <br>metadata:   <br>  annotations:     <br>    <strong>eks.amazonaws.com/role-arn: arn:aws:iam::</strong><strong><em>&lt;ACCOUNT_ID&gt;</em>:role/</strong><strong><em>&lt;IAM_ROLE_NAME&gt;<br> </em></strong><em> name: &lt;service account name. e.g sa-a&gt;<br>  namespace: &lt;your namespace A runs on&gt;</em></pre><p>If you do kubectl apply on this, it will create a secrets behind of the scene.</p><pre>$kubectl get serviceaccounts/sa-a -o yaml --namespace &lt;your namespace&gt;</pre><pre>.....<br><strong>secrets:<br>- name: sa-a-token-XXXX</strong></pre><h3>Attach Service Account to your deployments:</h3><p>In your deployment.yml, you need to specify the serviceAccountName explicitly, otherwise the pod would use the default service account.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name:a<br>spec:<br>  template:<br>    <strong>spec:<br>      serviceAccountName: sa-a</strong><br>    imagePullSecrets:<br>      -name: image-pull-secret<br>    containers:<br>      -name: a<br>.......</pre><h3>Verify your Service Account is working</h3><p>You can check the environment variable in your app pod to see if aws related parameter as highlighted below exists:</p><pre>$kubectl exec -n &lt;you namespace&gt; pods/&lt;pod name&gt; env|grep AWS</pre><pre><strong>AWS_ROLE_ARN=arn:aws:iam:&lt;Account No&gt;:role/&lt;role name&gt;</strong><br><strong>AWS_WEB_IDENTITY_TOKEN_FILE=/var/run/secrets/eks.amazonaws.com/serviceaccount/token</strong><br>AWS_STS_REGIONAL_ENDPOINTS=regional<br>AWS_REGION=us-east-1</pre><h3>Sample Java code using service account to access S3</h3><ul><li>pom.xml</li></ul><pre>&lt;dependencyManagement&gt;<br> &lt;dependencies&gt;<br>  &lt;dependency&gt;<br>   &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>   &lt;artifactId&gt;aws-java-sdk-bom&lt;/artifactId&gt;<br>   &lt;version&gt;1.11.717&lt;/version&gt;<br>   &lt;type&gt;pom&lt;/type&gt;<br>   &lt;scope&gt;import&lt;/scope&gt;<br>  &lt;/dependency&gt;<br> &lt;/dependencies&gt;<br>&lt;/dependencyManagement&gt;</pre><pre>&lt;dependencies&gt;</pre><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>  &lt;artifactId&gt;aws-java-sdk-s3&lt;/artifactId&gt;<br> &lt;/dependency&gt;<br> &lt;dependency&gt;<br>  &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>  &lt;artifactId&gt;aws-java-sdk-sts&lt;/artifactId&gt;<br> &lt;/dependency&gt;<br> &lt;dependency&gt;<br>  &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>  &lt;artifactId&gt;aws-java-sdk-iam&lt;/artifactId&gt;<br> &lt;/dependency&gt;</pre><pre>....</pre><pre>&lt;/dependencies&gt;</pre><ul><li>sample code to get list of file name in the given bucket.</li></ul><pre><strong>String</strong> bucketname = &quot;put your bucket name here&quot;;<br><strong>AWSCredentialsProvider</strong> provider = new DefaultAWSCredentialsProviderChain();<br><strong>AmazonS3</strong> s3 = AmazonS3ClientBuilder.standard().withCredentials(provider.GetCredentials()).build();</pre><pre><strong>ListObjectsV2Result</strong> result = s3.listObjectsV2(bucketname);<br><strong>return</strong> result.getObjectSummaries().stream().limit(20).map(S3ObjectSummary::getKey).collect(Collectors.toList());</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf4fb5926147" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/how-to-use-service-account-in-eks-cf4fb5926147">How to use Service Account in EKS</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Lambda Performance Optimization]]></title>
            <link>https://medium.com/lazy-tech-leader-series/aws-lambda-performance-optimization-bef05d97875b?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/bef05d97875b</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[operational-excellence]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 03:07:35 GMT</pubDate>
            <atom:updated>2022-07-16T04:14:56.436Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS lambda are a great product to allow you to run your logic without server. Today I want to highlight on the parts of how to use it <strong>smartly</strong>.</p><h4>Lambda Cold Start</h4><p>During lambda execution, there are <strong>cold start period</strong> and <strong>warm start period</strong>. To improve resource management and performance, the Lambda service retains the execution environment for a non-deterministic period of time. During this time, if another request arrives for the same function, the service may reuse the environment. This second request typically finishes more quickly, since the execution environment already exists and it’s not necessary to download the code and run the initialization code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vun0UnpCebjfaMVp.png" /></figure><p>We can leverage this feature and use it wisely for good purposes like: Instantiate AWS clients and database clients etc. In this way, it can avoid the logic of trying to establish new connection every single lambda execution.</p><p>Where are the cold start logic located? Please check the yellow section below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*HYQtgggCTWlB6sDy9gYwfA.png" /></figure><h4>Some other AWS Lambda Best Practice</h4><p>Below are the common best practices you should follow when using lambda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*_fXMR-4-tvGp0V1qRHh4TQ.png" /></figure><p>There is also a very good articles about how to operate lambda. I highly recommend you read all of them:</p><ul><li><a href="https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/">Operating Lambda: Performance optimization — Part 1</a></li><li><a href="https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-2/">Operating Lambda: Performance optimization — Part 2</a></li><li><a href="https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-3/">Operating Lambda: Performance optimization — Part 3</a></li></ul><h3>Security Concerns</h3><p>Lambda runs inside AWS managed VPC and by default have access to internet. For most of financial institutions, it is not acceptable. The solution is to attach lambda to your AWS VPC, the computing would still happen inside of AWS managed resources, but the network are controlled based on your VPC settings. so in this way, you can control what lambda can access.</p><p>I hope you enjoy the post. Happy Coding!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bef05d97875b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/aws-lambda-performance-optimization-bef05d97875b">AWS Lambda Performance Optimization</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use AWS SAML Authentication in Java]]></title>
            <link>https://medium.com/lazy-tech-leader-series/how-to-use-aws-saml-authentication-in-java-f6f56a30d451?source=rss----eb2eaf6dbfe---4</link>
            <guid isPermaLink="false">https://medium.com/p/f6f56a30d451</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aml]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Wu Jiaojiao & Li Yuansan]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 03:07:15 GMT</pubDate>
            <atom:updated>2022-07-13T08:00:30.201Z</atom:updated>
            <content:encoded><![CDATA[<p>If you work in a company, and want to move data from on prem to public cloud, e.g. AWS S3 service, programmatically. Before you can code, let us try to understand the infrastructure setup about the connectivity.</p><h4>Network Accessibility</h4><p>In most of the cases, how on-prem network connecting to AWS public cloud are setup in the diagram below. From your organization perspective, the customer network represents the on-prem Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*wKIbRC-v2gc41LDO.png" /></figure><p>In order for you to be able to connect to services sitting/routing from AWS VPC, the AWS client should know the “customer router/firewall” information. This is normally regarded as “Proxy Server”. It is the starting point to reach AWS network.</p><h4>Authentication</h4><p>If you are hosting a public available information, and no authentication are required, e.g. http connection. You should be able to use curl command with proxy setting to be able to establish the connection.</p><p>However, if you want to connect to AWS services, e.g. S3. and it requires specific role to be able to read and write. How does authentication work in this case?</p><p>I paste one of the common used authentication flow as below. The Enterprise section represents on Prem identify Provider. Most of companies use windows Active Directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Qxi6iuroUBD04lhL.png" /></figure><p>If you are using browser/aws cli/aws java client to connect to AWS, there are two main steps:</p><ul><li>Authenticate via your AD.</li><li>Get the SAML Assertion from your AD, and send to AWS Sts to authorize.</li></ul><h4>Code</h4><p>After understanding the network and authentication flow, now it is the time for coding:</p><ul><li>Step 1 — prepare the pom.xml</li></ul><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>    &lt;artifactId&gt;aws-java-sdk-iam&lt;/artifactId&gt;<br>    &lt;version&gt;1.11.444&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>    &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>    &lt;artifactId&gt;aws-java-sdk-sts&lt;/artifactId&gt;<br>    &lt;version&gt;1.11.444&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>    &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>    &lt;artifactId&gt;aws-java-sdk-ec2&lt;/artifactId&gt;<br>    &lt;version&gt;1.11.444&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>    &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>    &lt;artifactId&gt;aws-java-sdk-s3&lt;/artifactId&gt;<br>    &lt;version&gt;1.11.444&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>    &lt;groupId&gt;org.jsoup&lt;/groupId&gt;<br>    &lt;artifactId&gt;jsoup&lt;/artifactId&gt;<br>    &lt;version&gt;1.9.2&lt;/version&gt;<br>  &lt;/dependency&gt;</pre><ul><li>Step 2 — Example code to get credentials:</li></ul><pre>import com.amazonaws.ClientConfiguration;<br>import com.amazonaws.Protocol;<br>import com.amazonaws.auth.AWSStaticCredentialsProvider;<br>import com.amazonaws.auth.BasicAWSCredentials;<br>import com.amazonaws.auth.BasicSessionCredentials;<br>import com.amazonaws.services.securitytoken.AWSSecurityTokenService;<br>import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder;<br>import com.amazonaws.services.securitytoken.model.AssumeRoleWithSAMLRequest;<br>import com.amazonaws.services.securitytoken.model.AssumeRoleWithSAMLResult;<br>import com.amazonaws.services.securitytoken.model.Credentials;<br>import org.jsoup.Connection;<br>import org.jsoup.Jsoup;<br>import org.jsoup.nodes.Document;<br>import org.jsoup.nodes.Element;<br>import org.jsoup.parser.Parser;<br>import org.jsoup.select.Elements;<br><br>import java.io.IOException;<br>import java.net.URL;<br>import java.util.Base64;<br>import java.util.Map;<br><br>public class AWSClientWithADAuth {<br><br>    public static final String <em>ADFS_URL </em>= &quot;https://adfs.example.com/adfs/ls/IdpInitiatedSignOn.aspx?loginToRp=urn:amazon:webservices&quot;;<br>    public static final String <em>ADFS_HOST </em>= &quot;adfs.example.com&quot;;<br>    <br>    public BasicSessionCredentials authorizeWithSamlAssertion(String region, String roleARN) throws Exception {<br>        AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.<em>standard</em>().withRegion(region)<br>                .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(&quot;&quot;, &quot;&quot;)))<br>                .withClientConfiguration(<br>                        new ClientConfiguration().withProxyHost(&quot;proxy.example.net&quot;)<br>                                .withProxyPort(8443).withProtocol(Protocol.<em>HTTPS</em>)<br>                ).build();<br><br>        String samlAssertion = getSamlAssertion(&quot;AD&quot;, &quot;username&quot;, &quot;password&quot;);<br><br>        if (samlAssertion != null) {<br>            AssumeRoleWithSAMLRequest request = new AssumeRoleWithSAMLRequest()<br>                    .withRoleArn(roleARN).withPrincipalArn(extractPrincipalArn(samlAssertion,roleARN))<br>                    .withDurationSeconds(3600)<br>                    .withSAMLAssertion(samlAssertion);<br><br>            AssumeRoleWithSAMLResult assumeRoleWithSAMLResult = stsClient.assumeRoleWithSAML(request);<br>            Credentials credentials = assumeRoleWithSAMLResult.getCredentials();<br>            return new BasicSessionCredentials(credentials.getAccessKeyId(),<br>                    credentials.getSecretAccessKey(), credentials.getSessionToken());<br>        } else {<br>            throw new Exception(&quot;Unauthorized Access&quot;);<br>        }<br>    }<br>    <br>    private String getSamlAssertion(String domain, String principal, String credential)<br>            throws IOException {<br>        String userName = domain + &quot;\\&quot; + principal;<br><br>        Connection.Response initialResp = Jsoup.<em>connect</em>(<em>ADFS_URL</em>).execute();<br>        Document loginForm = initialResp.parse();<br>        Map&lt;String, String&gt; cookies = initialResp.cookies();<br>        Element loginElement = loginForm.getElementById(&quot;loginForm&quot;);<br><br>        if (loginElement != null){<br>            URL loginPostUrl = new URL(&quot;https&quot;, <em>ADFS_HOST</em>, loginElement.attr(&quot;action&quot;));<br>            cookies.clear();<br>            Connection conn = Jsoup.<em>connect</em>(loginPostUrl.toString());<br>            Document samlDoc =<br>                    conn.data(&quot;UserName&quot;, userName).data(&quot;Kmsi&quot;, &quot;false&quot;).data(&quot;Password&quot;, credential)<br>                            .method(Connection.Method.<em>POST</em>).execute().parse();<br>            Elements samlElements = samlDoc.getElementsByAttributeValue(&quot;name&quot;, &quot;SAMLResponse&quot;);<br>            if (samlElements.isEmpty()){<br>                throw new IOException(&quot;Invalid SAML Response.&quot;);<br>            } else {<br>                Element samlElement = samlElements.first();<br>                return samlElement.val();<br>            }<br>        }<br>        return null;<br>    }<br>    private String extractPrincipalArn(String samlAssertion, String roleARN) throws Exception {<br>        String assertion = new String(Base64.<em>getDecoder</em>().decode(samlAssertion), &quot;UTF-8&quot;);<br>        Document assertionDoc = Jsoup.<em>parse</em>(assertion, &quot;UTF-8&quot;, Parser.<em>xmlParser</em>());<br>        Elements samlAttribute = assertionDoc.getElementsByAttributeValue(&quot;name&quot;, &quot;https://aws.amazon.com/SAML/Attributes/Role&quot;);<br><br>        for (Element attribue: samlAttribute){<br>            Elements samlAttrValues = attribue.getElementsByTag(&quot;AttributeValue&quot;);<br><br>            for (Element samlRoleAttr: samlAttrValues){<br>                String samlRole = samlRoleAttr.text();<br>                if (samlRole.contains(roleARN)){<br>                    return samlRole.split(&quot;,&quot;)[0];<br>                }<br>            }<br>        }<br>        throw new Exception(&quot;You are not authorized to assume role: &quot;+ roleARN);<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6f56a30d451" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lazy-tech-leader-series/how-to-use-aws-saml-authentication-in-java-f6f56a30d451">How to use AWS SAML Authentication in Java</a> was originally published in <a href="https://medium.com/lazy-tech-leader-series">Lazy Tech Leader Series</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>