<?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>Forem: Ankush</title>
    <description>The latest articles on Forem by Ankush (@ankushbehera).</description>
    <link>https://forem.com/ankushbehera</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%2F637478%2F337e0bbb-2f27-4eb5-bee8-e61b5faf336c.jpeg</url>
      <title>Forem: Ankush</title>
      <link>https://forem.com/ankushbehera</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ankushbehera"/>
    <language>en</language>
    <item>
      <title>🔐 OWASP API Security — Why Every Developer Should Care (Java + AWS Context)</title>
      <dc:creator>Ankush</dc:creator>
      <pubDate>Sat, 20 Sep 2025 06:31:25 +0000</pubDate>
      <link>https://forem.com/ankushbehera/owasp-api-security-why-every-developer-should-care-java-aws-context-20ln</link>
      <guid>https://forem.com/ankushbehera/owasp-api-security-why-every-developer-should-care-java-aws-context-20ln</guid>
      <description>&lt;h2&gt;
  
  
  🌍 Summary
&lt;/h2&gt;

&lt;p&gt;APIs are everywhere — they &lt;strong&gt;power mobile apps, web services, and cloud-native systems&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
But APIs are also &lt;strong&gt;one of the most common attack surfaces&lt;/strong&gt; in modern software.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;OWASP API Security Top 10 (2021)&lt;/strong&gt; is a &lt;strong&gt;developer-focused guide&lt;/strong&gt; that explains the most critical API security risks.&lt;/p&gt;

&lt;p&gt;👉 In this blog, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Go through each of the &lt;strong&gt;10 risks&lt;/strong&gt; (A01–A10)&lt;/li&gt;
&lt;li&gt;🔍 Explain &lt;strong&gt;what they mean&lt;/strong&gt; in developer terms&lt;/li&gt;
&lt;li&gt;🛑 Show &lt;strong&gt;real-world scenarios&lt;/strong&gt; and how attacks happen&lt;/li&gt;
&lt;li&gt;🛠️ Outline &lt;strong&gt;solutions across multiple layers&lt;/strong&gt; (code, infra, design)&lt;/li&gt;
&lt;li&gt;💻 Provide &lt;strong&gt;Java (Spring Boot) and AWS examples&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🧩 Highlight &lt;strong&gt;design patterns&lt;/strong&gt; that help mitigate risks&lt;/li&gt;
&lt;li&gt;📚 Share &lt;strong&gt;lessons from real incidents&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🎯 &lt;strong&gt;The goal is simple:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Help developers &lt;strong&gt;design and build secure APIs&lt;/strong&gt; without slowing down delivery.&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 What is OWASP API Security Top 10 (2021)?
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Open Web Application Security Project (OWASP)&lt;/strong&gt; is a &lt;strong&gt;global non-profit community&lt;/strong&gt; that provides trusted guidance on secure software practices.&lt;/p&gt;

&lt;p&gt;Its &lt;strong&gt;API Security Top 10&lt;/strong&gt; highlights the &lt;strong&gt;most critical categories of API risks&lt;/strong&gt; developers must understand.&lt;br&gt;&lt;br&gt;
The &lt;strong&gt;2021 edition&lt;/strong&gt; is the latest, using &lt;strong&gt;codes A01–A10&lt;/strong&gt;, and is &lt;strong&gt;widely adopted&lt;/strong&gt; as a standard reference by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;👩‍💻 Developers&lt;/li&gt;
&lt;li&gt;🏗️ Architects&lt;/li&gt;
&lt;li&gt;🕵️ Auditors and Security Reviewers&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🔗 Quick Navigation
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;A01 — Broken Access Control&lt;/li&gt;
&lt;li&gt;A02 — Cryptographic Failures&lt;/li&gt;
&lt;li&gt;A03 — Injection&lt;/li&gt;
&lt;li&gt;A04 — Insecure Design&lt;/li&gt;
&lt;li&gt;A05 — Security Misconfiguration&lt;/li&gt;
&lt;li&gt;A06 — Vulnerable and Outdated Components&lt;/li&gt;
&lt;li&gt;A07 — Identification and Authentication Failures&lt;/li&gt;
&lt;li&gt;A08 — Software and Data Integrity Failures&lt;/li&gt;
&lt;li&gt;A09 — Logging and Monitoring Failures&lt;/li&gt;
&lt;li&gt;A10 — Server-Side Request Forgery (SSRF)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. A01:2021 — Broken Access Control
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Broken Access Control means users can &lt;strong&gt;perform actions or access information they are not authorized for&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
For example, a customer may change an account ID in the request and access another customer’s account.&lt;/p&gt;

&lt;p&gt;This happens when applications do not consistently enforce restrictions.&lt;br&gt;&lt;br&gt;
Proper security requires:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Role-Based Access Control (RBAC):&lt;/strong&gt; Broad permissions grouped by user roles&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attribute-Based Access Control (ABAC):&lt;/strong&gt; Finer-grained checks based on user or resource attributes such as ownership or department&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Insecure Direct Object Reference (IDOR):&lt;/strong&gt; Exploiting predictable identifiers in API requests&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Role-Based Access Control (RBAC):&lt;/strong&gt; Permissions mapped to roles such as Administrator, Customer, Auditor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attribute-Based Access Control (ABAC):&lt;/strong&gt; Permissions based on user or resource attributes (for example, owner ID, branch)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon Cognito / Keycloak:&lt;/strong&gt; Identity providers that issue JWTs with roles and attributes to enforce both role-based and attribute-based access control&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;A banking API endpoint:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/accounts/{id}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;👉 Customers can change the &lt;code&gt;id&lt;/code&gt; in the URL and view another person’s account because the application does not check ownership.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Enforce role-based access control (RBAC) and attribute-based access control (ABAC) using claims in JWTs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; API Gateway validates tokens before backend services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database level:&lt;/strong&gt; Use row-level security (restrict records by ownerId or tenantId)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Spring Boot)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@GetMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/accounts/{id}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@PreAuthorize&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hasRole('ADMIN') || #id == authentication.name"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Account&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@PathVariable&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt; 
    &lt;span class="c1"&gt;// Fetch account only if user is ADMIN or owner&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;accountService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="nc"&gt;Converter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Jwt&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AbstractAuthenticationToken&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;jwtAuth&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;jwt&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;auths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;GrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
        &lt;span class="c1"&gt;// Map roles from JWT claim&lt;/span&gt;
        &lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getClaimAsStringList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"roles"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;forEach&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; 
            &lt;span class="n"&gt;auths&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SimpleGrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ROLE_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;
        &lt;span class="c1"&gt;// Map scopes from JWT claim&lt;/span&gt;
        &lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getClaimAsStringList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"scope"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;forEach&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; 
            &lt;span class="n"&gt;auths&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SimpleGrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SCOPE_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;JwtAuthenticationToken&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auths&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getSubject&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;};&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Strategy Pattern&lt;/strong&gt; — Choose between &lt;strong&gt;role-based access control (RBAC)&lt;/strong&gt; or &lt;strong&gt;attribute-based access control (ABAC)&lt;/strong&gt; strategies dynamically.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prevents unauthorized data access&lt;/li&gt;
&lt;li&gt;Ensures consistent enforcement across systems&lt;/li&gt;
&lt;li&gt;Builds stronger trust with users&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Facebook (2019)&lt;/strong&gt; — A bug in the photo API exposed unpublished and private photos of 6.8M users to third-party apps because permissions were overly broad and access control checks failed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instagram (2020)&lt;/strong&gt; — An authorization flaw allowed attackers to retrieve private user account details by manipulating user IDs in API requests, bypassing ownership checks and exposing sensitive profile information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Uber (2016)&lt;/strong&gt; — Weak internal access controls gave employees broad visibility into rider trip data. Overly permissive systems lacked proper segregation of duties and failed to enforce strict authorization boundaries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Snapchat (2014)&lt;/strong&gt; — Public API flaw allowed enumeration of usernames and phone numbers, exposing 4.6M accounts. Missing rate limiting and insufficient authorization checks enabled attackers to harvest data at scale.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microsoft Power Apps (2021)&lt;/strong&gt; — Misconfigured default OData API settings exposed 38M records including personal and health data. Insecure defaults allowed anonymous public access to sensitive information across multiple organizations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  2. A02:2021 — Cryptographic Failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Cryptographic failures expose sensitive data when &lt;strong&gt;encryption is missing, weak, or misused&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Common mistakes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transmitting data over &lt;strong&gt;Hypertext Transfer Protocol (HTTP)&lt;/strong&gt; instead of &lt;strong&gt;Hypertext Transfer Protocol Secure (HTTPS)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Storing passwords in plain text&lt;/li&gt;
&lt;li&gt;Failing to rotate keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Attackers can intercept data, steal secrets, or modify information. Protecting data requires &lt;strong&gt;encryption in transit and at rest&lt;/strong&gt;, and secure storage of secrets.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transport Layer Security (TLS):&lt;/strong&gt; Encrypts data in transit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mutual Transport Layer Security (mTLS):&lt;/strong&gt; Authenticates both client and server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Key Management Service (KMS):&lt;/strong&gt; Manages encryption keys and rotation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Secrets Manager / HashiCorp Vault:&lt;/strong&gt; Secure storage and automatic rotation of secrets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BCrypt:&lt;/strong&gt; Strong hashing algorithm for securely storing passwords&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;An API transmits login credentials over plain &lt;strong&gt;HTTP&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Attackers on the same Wi-Fi capture usernames and passwords because the connection is unencrypted.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Hash passwords with BCrypt; never log sensitive data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Use AWS Key Management Service (KMS) to encrypt storage; store secrets in Secrets Manager&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network level:&lt;/strong&gt; Enforce TLS 1.2+ and configure HTTP Strict Transport Security (HSTS)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Spring Boot + AWS)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_kms_key"&lt;/span&gt; &lt;span class="s2"&gt;"cust"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nx"&gt;enable_key_rotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_db_instance"&lt;/span&gt; &lt;span class="s2"&gt;"rds"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;storage_encrypted&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;kms_key_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_kms_key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cust&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;requiresChannel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;requiresSecure&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;httpStrictTransportSecurity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;hs&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;maxAgeInSeconds&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;31536000&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;

&lt;span class="nc"&gt;PasswordEncoder&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BCryptPasswordEncoder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPassword&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;encode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rawPassword&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Facade Pattern&lt;/strong&gt; — Centralize all encryption and hashing logic behind a single interface to ensure consistency across services.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prevents sensitive data leaks&lt;/li&gt;
&lt;li&gt;Protects communications from eavesdropping&lt;/li&gt;
&lt;li&gt;Reduces risk of stolen credentials&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Equifax (2017)&lt;/strong&gt; — Poor encryption and unpatched systems led to a breach of 147 million records, including social security numbers and financial data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Yahoo (2013–2014)&lt;/strong&gt; — Weak cryptography and stolen credentials resulted in breaches of over 3 billion accounts, exposing email content and personal information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Heartbleed (2014)&lt;/strong&gt; — A flaw in OpenSSL’s implementation of TLS allowed attackers to read server memory and extract private keys.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Marriott (2018)&lt;/strong&gt; — Inadequate cryptographic practices contributed to exposure of 500 million customer records, including passport and payment details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Panera Bread (2018)&lt;/strong&gt; — An API exposed customer data such as emails and loyalty card numbers because sensitive endpoints were not secured with HTTPS.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3. A03:2021 — Injection
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Injection occurs when &lt;strong&gt;untrusted input is executed as part of a command or query&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Classic examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL Injection&lt;/li&gt;
&lt;li&gt;NoSQL Injection&lt;/li&gt;
&lt;li&gt;Command Injection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Attackers manipulate input to change the behavior of queries, retrieve unauthorized data, or run arbitrary commands.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parameterized Queries:&lt;/strong&gt; Prevent inputs from being executed as code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Input Validation:&lt;/strong&gt; Enforce data rules with annotations such as &lt;code&gt;@Valid&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web Application Firewall (WAF):&lt;/strong&gt; Detect and block common injection payloads&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;A login form concatenates user input into a SQL query.&lt;br&gt;&lt;br&gt;
Input like &lt;code&gt;' OR '1'='1&lt;/code&gt; bypasses authentication and returns all users.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Use parameterized queries and validate all inputs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Deploy a Web Application Firewall (WAF) to detect injection attempts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database level:&lt;/strong&gt; Run queries with least-privilege accounts to limit damage&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Spring Boot + Java)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Query&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"select u from User u where u.username=:u and u.tenantId=:t"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@Param&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"u"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@Param&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"t"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;LoanReq&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@NotBlank&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;custId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@Positive&lt;/span&gt; &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;amt&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;

&lt;span class="nd"&gt;@PostMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/loan"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loan&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@Valid&lt;/span&gt; &lt;span class="nd"&gt;@RequestBody&lt;/span&gt; &lt;span class="nc"&gt;LoanReq&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Business logic for loan creation&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Builder Pattern&lt;/strong&gt; — Construct queries safely step by step, ensuring that user inputs are always treated as data, not executable code.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Eliminates one of the most common attack methods&lt;/li&gt;
&lt;li&gt;Ensures inputs are consistently treated as data, not code&lt;/li&gt;
&lt;li&gt;Protects both SQL and NoSQL databases&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sony Pictures (2011)&lt;/strong&gt; — SQL Injection attack leaked millions of records, including customer details and sensitive company data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TalkTalk (2015)&lt;/strong&gt; — SQL Injection exposed customer personal data and financial information of over 150,000 users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Heartland Payment Systems (2008)&lt;/strong&gt; — SQL Injection exploited payment systems, resulting in the theft of 130 million credit card numbers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;British Airways (2018)&lt;/strong&gt; — Poor input handling on the airline’s website led to customer data exposure, including names, travel information, and payment details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tesla (2018)&lt;/strong&gt; — A NoSQL Injection vulnerability exposed internal cloud resources, giving attackers the ability to run malicious code and mine cryptocurrency.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  4. A04:2021 — Insecure Design
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Insecure Design refers to weaknesses in the &lt;strong&gt;application’s workflow or architecture&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Even if the code is written securely, poor design can allow attacks such as brute force login attempts, replay attacks, or missing rate limiting.&lt;/p&gt;

&lt;p&gt;A secure design must consider &lt;strong&gt;abuse cases&lt;/strong&gt; and build protections into workflows before implementation.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Brute Force Protection:&lt;/strong&gt; Limit repeated login attempts to stop password guessing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay Protection:&lt;/strong&gt; Use nonces or timestamps to prevent request reuse&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Factor Authentication (MFA):&lt;/strong&gt; Add a second factor for sensitive operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Gateway Rate Limits:&lt;/strong&gt; Control excessive traffic to protect backends&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;A login API allows &lt;strong&gt;unlimited login attempts&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Attackers run automated bots to try millions of passwords until one succeeds, gaining unauthorized access.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Add Multi-Factor Authentication (MFA) and enforce unique nonces for sensitive actions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Use API Gateway or Web Application Firewall (WAF) to rate limit requests&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network level:&lt;/strong&gt; Block Internet Protocol (IP) addresses with repeated failed attempts&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Infrastructure Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;rate_based_statement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nx"&gt;limit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; 
  &lt;span class="nx"&gt;aggregate_key_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"IP"&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Template Method Pattern&lt;/strong&gt; — Define secure steps in workflows (for example: Login → Multi-Factor Authentication → Success).&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reduces risks by embedding security into workflows&lt;/li&gt;
&lt;li&gt;Protects against brute force and replay attacks&lt;/li&gt;
&lt;li&gt;Ensures sensitive operations always follow strict, secure steps&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;LinkedIn (2012)&lt;/strong&gt; — Weak password protection and missing brute force defenses allowed attackers to steal 6.5 million password hashes from the social networking platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Apple iCloud (2014)&lt;/strong&gt; — Lack of strong rate limiting enabled brute force attacks on celebrity accounts, leading to leaks of private photos.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;PlayStation Network (2011)&lt;/strong&gt; — Insecure design and inadequate protection layers caused one of the largest breaches in gaming history, exposing personal and payment data of 77 million accounts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OWASP Juice Shop (Ongoing)&lt;/strong&gt; — Training application intentionally demonstrates insecure design flaws, such as weak workflows and missing rate limiting, to highlight how insecure patterns are exploited in practice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Coinbase (2019)&lt;/strong&gt; — A design flaw allowed replay of valid requests, potentially enabling attackers to repeat transactions or actions without detection.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  5. A05:2021 — Security Misconfiguration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Security misconfigurations are among the most common issues.&lt;br&gt;&lt;br&gt;
Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open ports&lt;/li&gt;
&lt;li&gt;Unnecessary services&lt;/li&gt;
&lt;li&gt;Default credentials&lt;/li&gt;
&lt;li&gt;Overly broad Cross-Origin Resource Sharing (CORS) settings&lt;/li&gt;
&lt;li&gt;Missing security headers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They leave APIs vulnerable even when the code itself is correct.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Origin Resource Sharing (CORS) Policy:&lt;/strong&gt; Restrict requests to trusted domains&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Headers:&lt;/strong&gt; Add HTTP Strict Transport Security (HSTS), X-Content-Type-Options, and others&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Config:&lt;/strong&gt; Continuously checks resources against security rules&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;An API allows Cross-Origin Resource Sharing (CORS) requests from any origin (&lt;code&gt;*&lt;/code&gt;).&lt;br&gt;&lt;br&gt;
Malicious websites can send API requests on behalf of logged-in users, stealing their data or performing unauthorized actions.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Configure strict Cross-Origin Resource Sharing (CORS) policies and enable standard security headers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Use AWS Config to enforce security baselines across cloud resources&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network level:&lt;/strong&gt; Restrict open ports using Security Groups or firewall rules&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Spring Boot Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Bean&lt;/span&gt; 
&lt;span class="nc"&gt;WebMvcConfigurer&lt;/span&gt; &lt;span class="nf"&gt;cors&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;addMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/**"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;allowedOrigins&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://bank.com"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;allowedMethods&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"GET"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;allowCredentials&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Facade Pattern&lt;/strong&gt; — Centralize configuration in one layer to ensure consistency across all services.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prevents attackers from exploiting weak defaults&lt;/li&gt;
&lt;li&gt;Ensures secure settings across environments&lt;/li&gt;
&lt;li&gt;Reduces risk of accidental data exposure&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Capital One (2019)&lt;/strong&gt; — Misconfigured AWS firewall exposed 100 million records, including credit card applications and customer data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microsoft Power Apps (2021)&lt;/strong&gt; — Misconfigured API settings exposed 38 million records across multiple organizations, including government and healthcare.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;NASA (2018)&lt;/strong&gt; — Misconfigurations in cloud and internal systems exposed sensitive project data and credentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verizon (2017)&lt;/strong&gt; — An open Amazon Simple Storage Service (S3) bucket exposed millions of customer records, including call center logs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accenture (2017)&lt;/strong&gt; — Misconfigured cloud storage exposed internal company data and access credentials publicly on the internet.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  6. A06:2021 — Vulnerable and Outdated Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;This risk arises when applications rely on &lt;strong&gt;outdated libraries, frameworks, or runtime environments&lt;/strong&gt; with known security flaws.&lt;br&gt;&lt;br&gt;
Attackers exploit these weaknesses even if your own code is secure.&lt;/p&gt;

&lt;p&gt;Common issues include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ignoring dependency updates&lt;/li&gt;
&lt;li&gt;Using unpatched container images&lt;/li&gt;
&lt;li&gt;Failing to track the software supply chain&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Software Composition Analysis (SCA):&lt;/strong&gt; Tools such as OWASP Dependency-Check or Snyk scan dependencies for known vulnerabilities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Software Bill of Materials (SBOM):&lt;/strong&gt; A complete list of all components; CycloneDX is a standard format&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable Images:&lt;/strong&gt; Rebuild container images regularly to include the latest security patches&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;A banking application continues using the vulnerable Log4j library.&lt;br&gt;&lt;br&gt;
Attackers exploit the &lt;strong&gt;Log4Shell&lt;/strong&gt; flaw to execute remote code on the server.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Use Software Composition Analysis (SCA) tools in Continuous Integration / Continuous Delivery (CI/CD) pipelines to detect vulnerable libraries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Build golden Amazon Machine Images (AMIs) or Docker images and update them regularly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process level:&lt;/strong&gt; Generate Software Bill of Materials (SBOMs) and break builds when critical Common Vulnerabilities and Exposures (CVEs) are found&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Maven Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mvn org.owasp:dependency-check-maven:check
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Observer Pattern&lt;/strong&gt; — React automatically when vulnerabilities are discovered (for example, pipeline alerts trigger build failures).&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prevents exploitation of known flaws&lt;/li&gt;
&lt;li&gt;Keeps applications aligned with security patches&lt;/li&gt;
&lt;li&gt;Improves visibility into dependencies&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Log4Shell (2021)&lt;/strong&gt; — Vulnerability in Log4j impacted millions of systems worldwide, enabling remote code execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Equifax (2017)&lt;/strong&gt; — Failure to patch an Apache Struts vulnerability led to a massive breach, exposing personal data of 147 million people.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Heartbleed (2014)&lt;/strong&gt; — A flaw in outdated OpenSSL versions allowed attackers to read server memory and steal private keys.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Drupalgeddon (2014)&lt;/strong&gt; — A critical vulnerability in the Drupal content management system was widely exploited when websites failed to update promptly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WordPress Plugins (Multiple Years)&lt;/strong&gt; — Numerous unpatched plugins have caused widespread compromises of websites running WordPress.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  7. A07:2021 — Identification and Authentication Failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Weak authentication or mismanaged sessions allow attackers to impersonate users.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long-lived tokens&lt;/li&gt;
&lt;li&gt;Missing validation of token claims&lt;/li&gt;
&lt;li&gt;Weak passwords&lt;/li&gt;
&lt;li&gt;Using Basic Authentication between services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Secure APIs require strong identity validation, careful token management, and secure service-to-service authentication.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OpenID Connect (OIDC):&lt;/strong&gt; An identity layer built on top of OAuth 2.0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSON Web Tokens (JWT):&lt;/strong&gt; Secure tokens carrying claims, which must always be validated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mutual Transport Layer Security (mTLS):&lt;/strong&gt; Ensures services authenticate and trust each other&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon Cognito / Keycloak:&lt;/strong&gt; Platforms that manage users, tokens, and Multi-Factor Authentication (MFA)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;An API issues JWTs valid for 24 hours without validating audience or expiry.&lt;br&gt;&lt;br&gt;
If stolen, attackers can impersonate users for a full day.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Validate token issuer, audience, and expiry. Use short-lived tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Use mTLS between services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway level:&lt;/strong&gt; Enforce token validation at the API Gateway&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Java Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;JwtDecoder&lt;/span&gt; &lt;span class="n"&gt;dec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NimbusJwtDecoder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withJwkSetUri&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwksUri&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;dec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setJwtValidator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;JwtClaimValidator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;"aud"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aud&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;aud&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"api://svc"&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Decorator Pattern&lt;/strong&gt; — Enrich tokens with roles or scopes during validation to strengthen identity checks.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stops impersonation from stolen tokens&lt;/li&gt;
&lt;li&gt;Ensures only valid, trusted sessions are used&lt;/li&gt;
&lt;li&gt;Strengthens identity handling across systems&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Uber (2016)&lt;/strong&gt; — Authentication failures exposed driver and rider data, highlighting weak internal token management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microsoft (2021)&lt;/strong&gt; — Token misconfigurations in Azure Active Directory enabled exploits that allowed attackers to escalate privileges.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Facebook (2018)&lt;/strong&gt; — A flaw in access tokens exposed 50 million accounts, allowing attackers to take over user sessions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instagram (2019)&lt;/strong&gt; — API flaws exposed session tokens, leaving user accounts vulnerable to hijacking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Google+ (2018)&lt;/strong&gt; — Bugs in token handling exposed user data, ultimately contributing to the shutdown of the platform.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  8. A08:2021 — Software and Data Integrity Failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;This risk arises when &lt;strong&gt;code, dependencies, or deployment pipelines are tampered with&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
If APIs rely on unsigned packages, compromised container images, or unverified updates, attackers can inject malicious code into production systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cosign:&lt;/strong&gt; Tool to sign and verify container images&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open Policy Agent (OPA):&lt;/strong&gt; Prevents unsigned or unverified resources from being deployed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Argo Continuous Delivery (Argo CD) with GitOps:&lt;/strong&gt; Ensures deployments come from trusted Git repositories with full traceability&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;An attacker pushes a malicious Docker image to a registry.&lt;br&gt;&lt;br&gt;
The Kubernetes cluster deploys it without verification, running untrusted code in production.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pipeline level:&lt;/strong&gt; Sign all container images with Cosign&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cluster level:&lt;/strong&gt; Use Open Policy Agent (OPA) Gatekeeper to block unsigned resources&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process level:&lt;/strong&gt; Adopt GitOps practices to ensure deployments come only from trusted repositories&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cosign sign &lt;span class="nv"&gt;$ECR&lt;/span&gt;/app:1.2.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Proxy Pattern&lt;/strong&gt; — Admission controllers act as intermediaries that intercept and block unverified deployments before they reach production.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prevents supply chain attacks&lt;/li&gt;
&lt;li&gt;Ensures only trusted code runs in production&lt;/li&gt;
&lt;li&gt;Adds accountability and traceability to deployments&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SolarWinds (2020)&lt;/strong&gt; — A supply chain compromise inserted malicious code into software updates, impacting thousands of organizations worldwide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Codecov (2021)&lt;/strong&gt; — A malicious update to the Codecov Bash uploader exfiltrated credentials and tokens from customer environments for months before detection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Event-Stream (2018)&lt;/strong&gt; — A popular Node Package Manager (NPM) library was backdoored, harvesting cryptocurrency wallet data from applications using the dependency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Asus Live Update (2019)&lt;/strong&gt; — Attackers distributed signed malware through Asus’s official Live Update utility, compromising hundreds of thousands of devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;PHP Git Server (2021)&lt;/strong&gt; — A backdoored commit was briefly added to the official PHP source code repository, potentially impacting all downstream deployments.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  9. A09:2021 — Logging and Monitoring Failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Without proper logging and monitoring, attacks go undetected.&lt;br&gt;&lt;br&gt;
APIs may fail to log failed login attempts, unusual traffic, or sensitive actions.&lt;br&gt;&lt;br&gt;
Without alerts, security teams cannot respond quickly, allowing attackers to persist undetected for months.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Security Information and Event Management (SIEM):&lt;/strong&gt; Centralize and analyze logs (examples: Splunk, ELK stack, AWS Security Hub)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS GuardDuty:&lt;/strong&gt; Detects anomalies in logs and network traffic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trace Identifiers (Trace IDs):&lt;/strong&gt; Correlate logs across distributed services&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;A login API does not log failed attempts.&lt;br&gt;&lt;br&gt;
Attackers use brute force techniques for months without detection.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Log authentication attempts and assign trace identifiers (Trace IDs)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure level:&lt;/strong&gt; Centralize logs in Amazon CloudWatch or an ELK stack&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring level:&lt;/strong&gt; Use AWS GuardDuty or similar tools for anomaly alerts&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Java Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@EventListener&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;onFail&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AbstractAuthenticationFailureEvent&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
 &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;warn&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"auth_fail user={} reason={}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; 
   &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAuthentication&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getException&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getMessage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Observer Pattern&lt;/strong&gt; — Events trigger logging and alerting actions automatically.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Detects attacks early&lt;/li&gt;
&lt;li&gt;Enables forensic investigation&lt;/li&gt;
&lt;li&gt;Improves operational visibility&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Equifax (2017)&lt;/strong&gt; — Delayed detection of exploitation worsened the impact of an already critical data breach.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target (2013)&lt;/strong&gt; — Security alerts were ignored, allowing the breach to persist for weeks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;British Airways (2018)&lt;/strong&gt; — Poor logging delayed discovery of data theft, exposing hundreds of thousands of customer records.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SolarWinds (2020)&lt;/strong&gt; — Weak monitoring allowed the supply chain attack to persist undetected for months.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capital One (2019)&lt;/strong&gt; — Logs eventually helped investigators trace the AWS metadata breach.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  10. A10:2021 — Server-Side Request Forgery (SSRF)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔎 Explanation
&lt;/h3&gt;

&lt;p&gt;Server-Side Request Forgery (SSRF) occurs when an API makes requests to URLs supplied by users without validation.&lt;br&gt;&lt;br&gt;
Attackers can trick servers into connecting to internal services or cloud metadata endpoints, stealing credentials or bypassing firewalls.&lt;/p&gt;




&lt;h3&gt;
  
  
  📝 Notes &amp;amp; Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS Instance Metadata Service v2 (IMDSv2):&lt;/strong&gt; Requires a session token, mitigating metadata theft&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes NetworkPolicy:&lt;/strong&gt; Blocks outbound requests to sensitive IP ranges&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbound Proxy:&lt;/strong&gt; Centralizes and filters all outgoing requests&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💥 Example Scenario
&lt;/h3&gt;

&lt;p&gt;An API fetches files from a user-supplied URL.&lt;br&gt;&lt;br&gt;
An attacker requests &lt;code&gt;http://169.254.169.254/&lt;/code&gt; and retrieves AWS credentials from the metadata service.&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application level:&lt;/strong&gt; Validate URLs and allowlist only trusted partner domains&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network level:&lt;/strong&gt; Block internal ranges using Kubernetes NetworkPolicy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud level:&lt;/strong&gt; Enforce AWS IMDSv2 for all instances&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💻 Code (Java Example)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;InetAddress&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getByName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="o"&gt;()).&lt;/span&gt;&lt;span class="na"&gt;getHost&lt;/span&gt;&lt;span class="o"&gt;()).&lt;/span&gt;&lt;span class="na"&gt;getHostAddress&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;startsWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"169.254."&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="no"&gt;ALLOWED&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; 
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ResponseStatusException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;BAD_REQUEST&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🎨 Design Pattern
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Chain of Responsibility Pattern&lt;/strong&gt; — Multiple validation steps are applied to outbound requests, ensuring only safe traffic is allowed.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stops attackers from abusing internal networks&lt;/li&gt;
&lt;li&gt;Protects cloud metadata services&lt;/li&gt;
&lt;li&gt;Ensures outbound calls are controlled and secure&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚨 Real Incidents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Capital One (2019)&lt;/strong&gt; — Server-Side Request Forgery (SSRF) exploited AWS metadata endpoint, exposing 100 million records.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tesla Cloud (2018)&lt;/strong&gt; — Server-Side Request Forgery (SSRF) allowed attackers to access cloud systems and run unauthorized cryptocurrency mining.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alibaba Cloud (2020)&lt;/strong&gt; — Server-Side Request Forgery (SSRF) flaws exposed internal cloud services of customers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft Azure (2017)&lt;/strong&gt; — Server-Side Request Forgery (SSRF) in services exposed sensitive credentials from metadata endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jira (2019)&lt;/strong&gt; — Server-Side Request Forgery (SSRF) vulnerability in Atlassian Jira exposed internal customer data.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🏁 Final Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Treat &lt;strong&gt;security as a design constraint&lt;/strong&gt;, not an afterthought.&lt;/li&gt;
&lt;li&gt;Apply &lt;strong&gt;layered defenses&lt;/strong&gt;: code, infrastructure, and process.&lt;/li&gt;
&lt;li&gt;Bake controls into &lt;strong&gt;pipelines and platforms&lt;/strong&gt; so they are hard to bypass.&lt;/li&gt;
&lt;li&gt;Keep &lt;strong&gt;documentation and runbooks&lt;/strong&gt; close to the code so teams can respond fast.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Bottom line:&lt;/strong&gt; Your APIs are the front door to your business — &lt;strong&gt;build them to be safe by default&lt;/strong&gt; and resilient when things go wrong.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use this guide as a &lt;strong&gt;checklist&lt;/strong&gt; for design reviews, threat modeling, and production readiness of your APIs.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>owasp</category>
      <category>apisecurity</category>
      <category>java</category>
      <category>aws</category>
    </item>
    <item>
      <title>A Complete Guide To Deploy GitHub Project on Amazon EC2 Using GitHub Actions and AWS CodeDeploy</title>
      <dc:creator>Ankush</dc:creator>
      <pubDate>Fri, 28 May 2021 20:08:59 +0000</pubDate>
      <link>https://forem.com/ankushbehera/a-complete-guide-to-deploy-github-project-on-amazon-ec2-using-github-actions-and-aws-codedeploy-3f0b</link>
      <guid>https://forem.com/ankushbehera/a-complete-guide-to-deploy-github-project-on-amazon-ec2-using-github-actions-and-aws-codedeploy-3f0b</guid>
      <description>&lt;h1&gt;
  
  
  Auto Deploy in Amazon EC2 on Git Commit. A complete guide to configure CodeDeploy and GitHub CI/CD Action.
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54j0kdubyd5mxsmec7ys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54j0kdubyd5mxsmec7ys.png" alt="image" width="800" height="141"&gt;&lt;/a&gt; &lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;




&lt;ul&gt;
&lt;li&gt;Create a &lt;a href="https://github.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; account.&lt;/li&gt;
&lt;li&gt;Create &lt;a href="https://console.aws.amazon.com/console/home" rel="noopener noreferrer"&gt;AWS&lt;/a&gt; Account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;




&lt;ul&gt;
&lt;li&gt;Create IAM Role for EC2 and CodeDeploy&lt;/li&gt;
&lt;li&gt;Create EC2 Instance&lt;/li&gt;
&lt;li&gt;Launch EC2 Instance&lt;/li&gt;
&lt;li&gt;Install CodeDeploy Agent on EC2 Instance&lt;/li&gt;
&lt;li&gt;CodeDeploy Service Configuration&lt;/li&gt;
&lt;li&gt;GitHub Project&lt;/li&gt;
&lt;li&gt;GitHub Action&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;




&lt;blockquote&gt;
&lt;p&gt;Select a particular region of AWS Services which CodeDeploy Agent and GitHub will use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Create IAM Role For EC2 and CodeDeploy &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26bulqgskw5bpu64r0kl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26bulqgskw5bpu64r0kl.png" alt="image" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Create a role for &lt;strong&gt;EC2 Instance&lt;/strong&gt; - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;AWS Service&lt;/strong&gt; as &lt;em&gt;trusted entity&lt;/em&gt; and &lt;strong&gt;EC2&lt;/strong&gt; as &lt;em&gt;usecase&lt;/em&gt;, click on &lt;em&gt;Next:Permissions&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;On the Permissions page, select &lt;strong&gt;AmazonEC2RoleforAWSCodeDeploy&lt;/strong&gt; Policy and Click on &lt;em&gt;Next:Tags&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Ignore the tags and click &lt;em&gt;Next:Review&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Provide the role name as &lt;strong&gt;EC2_Role&lt;/strong&gt; on the review page.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46kuzgo4qxpc639girdl.png" alt="image" width="800" height="798"&gt;
&lt;/li&gt;
&lt;li&gt;Open the EC2_Role and go to &lt;em&gt;Trust Relationships&lt;/em&gt;, then &lt;em&gt;Edit Trust Relationship&lt;/em&gt; and paste below policy -
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"Service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ec2.amazonaws.com"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sts:AssumeRole"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firtiqqgvv9uig7zxlist.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firtiqqgvv9uig7zxlist.png" alt="image" width="620" height="554"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Now we will create a role for &lt;strong&gt;CodeDeploy&lt;/strong&gt;.&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select &lt;em&gt;AWS Service&lt;/em&gt; as &lt;em&gt;trusted entity&lt;/em&gt; and &lt;em&gt;EC2&lt;/em&gt; as &lt;em&gt;usecase&lt;/em&gt;, click on &lt;em&gt;Next:Permissions&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;On the Permissions page, select the below policy and Click on &lt;em&gt;Next:Tags&lt;/em&gt;.
&lt;code&gt;AmazonEC2FullAccess, AWSCodeDeployFullAccess, AdministratorAccess, AWSCodeDeployRole&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Tags can be ignored, click on &lt;em&gt;Next:Review&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Provide the role name as &lt;strong&gt;CodeDeploy_Role&lt;/strong&gt; on the review page.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy6l3k4yjo76yvbwu2ut1.png" alt="image" width="800" height="413"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once CodeDeploy Role created, Open the CodeDeploy_Role and go to &lt;em&gt;Trust Relationships&lt;/em&gt; then &lt;em&gt;Edit Trust Relationship&lt;/em&gt; and use below policy -&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"codedeploy.amazonaws.com"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sts:AssumeRole"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Create EC2 Instance&lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To create an EC2 instance, Go to EC2 Dashboard on AWS Management Console and click on &lt;strong&gt;Launch Instance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;On the AIM page, You can select any &lt;em&gt;Volume Type&lt;/em&gt; based on your requirement. This article will choose &lt;em&gt;Free Tier&lt;/em&gt; &lt;strong&gt;Amazon Linux 2 AMI (HVM), SSD Volume Type&lt;/strong&gt; and &lt;strong&gt;64-bit (x86)&lt;/strong&gt; Volume and click on &lt;em&gt;select&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;t2.micro&lt;/strong&gt; in &lt;em&gt;Choose Instance Typ&lt;/em&gt; page and proceed to &lt;em&gt;Configure Instance&lt;/em&gt; page.&lt;/p&gt;

&lt;p&gt;To establish the connection between EC2 instance and codeDeploy, Select &lt;strong&gt;EC2_Role&lt;/strong&gt;, which we created before.&lt;/p&gt;

&lt;p&gt;On the &lt;em&gt;Tag page&lt;/em&gt;, add a tag called &lt;strong&gt;development&lt;/strong&gt;. The tag will require creating a &lt;em&gt;codeDeploy&lt;/em&gt; service.&lt;/p&gt;

&lt;p&gt;In &lt;em&gt;Configure Security Group&lt;/em&gt; page &lt;em&gt;Add Rule&lt;/em&gt; called &lt;strong&gt;All traffic&lt;/strong&gt;, select &lt;em&gt;source&lt;/em&gt; called &lt;strong&gt;anywhere&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This rule will enable you to connect the Instance from anywhere.&lt;br&gt;
  &lt;strong&gt;NOTE&lt;/strong&gt; - This is not advisable in the Production environment.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Select the &lt;em&gt;review&lt;/em&gt; page, then &lt;em&gt;Launch&lt;/em&gt; the Instance. Wait for a few minutes to start the EC2 Instance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you want to access the Instance (ssh) from your local system, create a new &lt;em&gt;Key Pair&lt;/em&gt; and download the key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsbfckiuolr4y1oj5ilt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsbfckiuolr4y1oj5ilt.png" alt="image" width="800" height="649"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc66iy10uzgmv6dygz5cl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc66iy10uzgmv6dygz5cl.png" alt="image" width="800" height="839"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Launch EC2 Instance &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Once Instance is up and running, Right-click on &lt;em&gt;instance id&lt;/em&gt; and click on &lt;em&gt;connect&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;On the next page, Take a note of the &lt;strong&gt;Public IP Address&lt;/strong&gt; and &lt;em&gt;connect&lt;/em&gt; using the default &lt;strong&gt;User name&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd9853dwfnc7hldoy7n9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd9853dwfnc7hldoy7n9.png" alt="image" width="800" height="972"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq2m1mtoonxwf6csjd53l.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq2m1mtoonxwf6csjd53l.jpg" alt="photo-1576267423429-569309b31e84" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Install CodeDeploy Agent on EC2 Instance &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;TO Deploy the git repo by using CodeDeploy Service, &lt;strong&gt;codeDeploy-agent&lt;/strong&gt; must install in the EC2 instance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Use the below commands to install codedeploy-agent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;wget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://bucket-name.s3.region-identifier.amazonaws.com/latest/install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;bucket-name is the Amazon S3 bucket containing the CodeDeploy Resource Kit files for your region. region-identifier is the identifier for your region.&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/resource-kit.html#resource-kit-bucket-names" rel="noopener noreferrer"&gt;list of bucket names and region identifiers&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example - &lt;code&gt;wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ./install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./install auto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service codedeploy-agent start 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  CodeDeploy Service Configuration &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;




&lt;p&gt;AWS &lt;a href="https://docs.amazonaws.cn/en_us/codedeploy/latest/userguide/welcome.html" rel="noopener noreferrer"&gt;CodeDeploy Service&lt;/a&gt; will automate the GitHub application deployment to EC2.&lt;/p&gt;

&lt;p&gt;Create an Application name called &lt;strong&gt;Git_Application&lt;/strong&gt; with &lt;em&gt;compute platform&lt;/em&gt; &lt;strong&gt;EC2/On-premises&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GitHub Action will use the application name.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhciskx6rrwq0r4m3whw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhciskx6rrwq0r4m3whw6.png" alt="image" width="800" height="588"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Once Application Created, Create a &lt;em&gt;Deployment Group&lt;/em&gt; and name &lt;strong&gt;development_gropup&lt;/strong&gt;. Get the &lt;em&gt;Role ARN&lt;/em&gt; from CodeDeploy_Role, which we created before and put in the service role.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GitHub Action will use the deployment Group name.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Choose &lt;strong&gt;In-place&lt;/strong&gt; &lt;em&gt;Deployment type&lt;/em&gt;. Select &lt;em&gt;Amazon Ec2 Instances&lt;/em&gt; environment configuration and Tag key &lt;strong&gt;development&lt;/strong&gt; to create AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;Select a schedule manager to install the CodeDeploy agent. Set &lt;em&gt;OneAtATime&lt;/em&gt; deployment setting and Create Deployment Group without a load balancer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqw1plmd8tpjscukpr7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqw1plmd8tpjscukpr7d.png" alt="image" width="800" height="746"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41sxab2cuhni6412y7f5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41sxab2cuhni6412y7f5.png" alt="image" width="800" height="565"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xivhirkebhcrl9ne7kb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xivhirkebhcrl9ne7kb.png" alt="image" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Once Deployment Group created, test the deployment by creating a Deployment with any name.&lt;/p&gt;

&lt;p&gt;Select &lt;em&gt;Revision Type&lt;/em&gt; &lt;strong&gt;My application is stored in GitHub&lt;/strong&gt;, and select &lt;strong&gt;Connect to GitHub&lt;/strong&gt; by providing the &lt;a href="https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token" rel="noopener noreferrer"&gt;GitHub token&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once connected to GitHub, Provide the repository name and last &lt;em&gt;Commit ID&lt;/em&gt;. Select &lt;em&gt;Overwrite the content&lt;/em&gt; and Create Deployment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3s5f3cv3auw4magmt33c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3s5f3cv3auw4magmt33c.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqya9yce6v5zxb09c21um.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqya9yce6v5zxb09c21um.png" alt="image" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait for a few minutes ⏳ .&lt;/p&gt;

&lt;p&gt;If Deployment status is unsuccessful, verify the deployment logs from ec2 instance &lt;code&gt;/var/log/aws/codedeploy-agent/codedeploy-agent.log&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Recreate the deployment and fix this first. Once it's successful, you can access the application from a web browser or postman.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --location --request GET 'http://{{[ec2_public_ip]}}:8080/student'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get &lt;code&gt;ec2_public_ip&lt;/code&gt; from EC2 Instance&lt;/p&gt;




&lt;h3&gt;
  
  
  GitHub Project&lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.github.com/en/github/getting-started-with-github/quickstart/fork-a-repo" rel="noopener noreferrer"&gt;Fork&lt;/a&gt; the &lt;a href="https://github.com/ankushbehera/spring-boot-mongo" rel="noopener noreferrer"&gt;spring-boot demo&lt;/a&gt; repository.&lt;/p&gt;

&lt;p&gt;This project is a spring-boot project which uses MongoDB. &lt;br&gt;
For project deployment, we will use &lt;a href="https://docs.docker.com/compose" rel="noopener noreferrer"&gt;docker-compose&lt;/a&gt;, which includes MongoDB.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html" rel="noopener noreferrer"&gt;&lt;code&gt;appspec.yml&lt;/code&gt;&lt;/a&gt; file used by codeDeploy to manage the deployment. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;setup.sh&lt;/code&gt; will install docker and docker-compose. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;run.sh&lt;/code&gt; is used for &lt;code&gt;docker-compose up&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.0&lt;/span&gt;
&lt;span class="na"&gt;os&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;linux&lt;/span&gt;
&lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
    &lt;span class="na"&gt;destination&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/ec2-user/spring-boot-mongo/&lt;/span&gt;
&lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;AfterInstall&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;setup.sh&lt;/span&gt;
     &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
     &lt;span class="na"&gt;runas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;
  &lt;span class="na"&gt;ApplicationStart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;run.sh&lt;/span&gt;
     &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
     &lt;span class="na"&gt;runas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  GitHub Action &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;First, create an &lt;a href="https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/id_users_create.html#id_users_create_console" rel="noopener noreferrer"&gt;IAM user&lt;/a&gt; with full &lt;code&gt;AWSCodeDeployFullAccess&lt;/code&gt; policy and generate an &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey" rel="noopener noreferrer"&gt;access key and secret access&lt;/a&gt; for the user to configure GitHub Action.&lt;/p&gt;

&lt;p&gt;Before configuring Action, set the environment in the GitHub repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzkmvr6y8pi9aqpdjlj6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzkmvr6y8pi9aqpdjlj6b.png" alt="image" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitHub repository changes will trigger &lt;a href="https://docs.github.com/en/actions" rel="noopener noreferrer"&gt;GitHub Action&lt;/a&gt;, which has two CI/CD job - &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The continuous-integration job will compile the code and run the JUnit Test cases.&lt;br&gt;
The continuous-deployment job will call AWS CodeDeploy Service -&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;application - &lt;strong&gt;Git_Application&lt;/strong&gt;&lt;br&gt;
deployment-group - &lt;strong&gt;development_gropup&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;Paste below YAML in action configuration and commit.&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;CI/CD Pipeline&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;continuous-integration&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# Step 1&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="c1"&gt;# Step 2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Set up JDK &lt;/span&gt;&lt;span class="m"&gt;11&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-java@v2&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;java-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;11'&lt;/span&gt;
          &lt;span class="na"&gt;distribution&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;adopt'&lt;/span&gt;
      &lt;span class="c1"&gt;# Step 3&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build Application and Run unit Test&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mvn -B test --file student-service/pom.xml&lt;/span&gt;

  &lt;span class="na"&gt;continuous-deployment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;continuous-integration&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github.ref == 'refs/heads/main'&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="c1"&gt;# Step 1&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Configure AWS credentials&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-actions/configure-aws-credentials@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;aws-access-key-id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.AWS_ACCESS_KEY_ID }}&lt;/span&gt;
          &lt;span class="na"&gt;aws-secret-access-key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.AWS_SECRET_ACCESS_KEY }}&lt;/span&gt;
          &lt;span class="na"&gt;aws-region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.AWS_REGION }}&lt;/span&gt;
     &lt;span class="c1"&gt;# Step 2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create CodeDeploy Deployment&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;aws deploy create-deployment \&lt;/span&gt;
            &lt;span class="s"&gt;--application-name Git_Application \&lt;/span&gt;
            &lt;span class="s"&gt;--deployment-group-name development_gropup \&lt;/span&gt;
            &lt;span class="s"&gt;--deployment-config-name CodeDeployDefault.OneAtATime \&lt;/span&gt;
            &lt;span class="s"&gt;--github-location repository=${{ github.repository }},commitId=${{ github.sha }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazrf0bp3qkm44qef91x3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazrf0bp3qkm44qef91x3.png" alt="image" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now make a change to your repository. Your changes should automatically deploy to your EC2 server.&lt;/p&gt;

&lt;p&gt;Access the application from a web browser or postman.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --location --request GET 'http://{{[ec2_public_ip]}}:8080/student'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get &lt;code&gt;ec2_public_ip&lt;/code&gt; from EC2 Instance&lt;/p&gt;

</description>
      <category>github</category>
      <category>aws</category>
      <category>devops</category>
      <category>codedeploy</category>
    </item>
  </channel>
</rss>
