<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roxane Fischer</title>
    <description>The latest articles on DEV Community by Roxane Fischer (@roxane_fischer_79570c1b5b).</description>
    <link>https://dev.to/roxane_fischer_79570c1b5b</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%2F1680084%2F8a27235e-5925-41ff-8bba-62bb144dc78f.jpg</url>
      <title>DEV Community: Roxane Fischer</title>
      <link>https://dev.to/roxane_fischer_79570c1b5b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roxane_fischer_79570c1b5b"/>
    <language>en</language>
    <item>
      <title>Identity and Access Management (IAM): A Deep Dive in AWS Resources</title>
      <dc:creator>Roxane Fischer</dc:creator>
      <pubDate>Tue, 04 Mar 2025 20:49:12 +0000</pubDate>
      <link>https://dev.to/roxane_fischer_79570c1b5b/identity-and-access-management-iam-a-deep-dive-in-aws-resources-1d7k</link>
      <guid>https://dev.to/roxane_fischer_79570c1b5b/identity-and-access-management-iam-a-deep-dive-in-aws-resources-1d7k</guid>
      <description>&lt;p&gt;Identity and Access Management (IAM) is central to any cloud infrastructure.&lt;/p&gt;

&lt;p&gt;At a high level, IAM is about assigning permissions to entities to allow or deny these entities to perform actions in your cloud environment. IAM is the foundation that the rest of your cloud environment is built on.&lt;/p&gt;

&lt;p&gt;Each cloud provider has their version of IAM. In this blog post we will specifically talk about IAM and related concepts in the context of Amazon Web Services (AWS). We will walk through a scenario where working with IAM through Terraform can lead to potential issues in your environment, and show how you can address these types of issues. Finally, we'll discuss some general best practices around IAM. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Identity and Access Management on AWS?
&lt;/h2&gt;

&lt;p&gt;When you interact with AWS, you first have to authenticate to the platform using your IAM credentials. IAM is the first barrier to entry to AWS.&lt;/p&gt;

&lt;p&gt;On AWS you have a few different types of entities, or &lt;strong&gt;principals&lt;/strong&gt;. A principal is an entity that you can assign permissions to allow it to perform actions in your AWS environment.&lt;/p&gt;

&lt;p&gt;The three most common types of entities are users, groups and roles. A &lt;strong&gt;user&lt;/strong&gt; is exactly what it sounds like. Your employees could have their own user on AWS.&lt;/p&gt;

&lt;p&gt;You can group users into &lt;strong&gt;groups&lt;/strong&gt; for easier administration. This allows you to assign permissions to many users that should have the same level of access.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;role&lt;/strong&gt; is a machine entity on AWS. When you build applications or use other AWS services you assign them roles, and to these roles you will assign permissions for what they are allowed to do in your AWS environment.&lt;/p&gt;

&lt;p&gt;Permissions on AWS come in the form of &lt;strong&gt;policies&lt;/strong&gt;. A policy is a collection of one or more specific permissions that says what a user or role is allowed to do. There are two major types of policies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Policies that you attach to entities (users, groups, roles).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Policies that you attach to resources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second type of policy is supported for a number of resources, including S3 buckets, SNS topics and API Gateways.&lt;/p&gt;

&lt;p&gt;You can use both types of policies together. If you are working on applications on AWS that span multiple AWS accounts you are required to use resource policies in many cases.&lt;/p&gt;

&lt;p&gt;The content of a policy consists of one or more policy statements. Each statement is one or more permissions that are either allowed or denied, for a given resource or resources.&lt;/p&gt;

&lt;p&gt;An example of a policy  that you assign to an entity is the AdministratorAccess policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "*",
            "Resource": "*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This policy consists of a single statement. This statement allows all actions on all resources. It is generally a policy you should be careful in assigning to your principals.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to break your infrastructure through IAM
&lt;/h2&gt;

&lt;p&gt;Given the importance of IAM on AWS it is clear that breaking an IAM resource can have far-reaching consequences. If your IAM roles, users, or policies change unexpectedly, it will impact your infrastructure and your applications.&lt;/p&gt;

&lt;p&gt;In this section we will go through a scenario for how your infrastructure can break through changes in IAM resources.&lt;/p&gt;

&lt;p&gt;You are a platform engineer at an organization that runs a microservices architecture on AWS. You work in the central platform team, and one of your responsibilities is to manage the shared AWS API Gateway resource that is the entrypoint to parts of your microservices architecture. The API Gateway handles internal and external traffic.&lt;/p&gt;

&lt;p&gt;A part of managing the API Gateway resource is to handle access control to the API using resource policies. A resource policy is an IAM policy where you can allow or deny access to the API and its methods.&lt;/p&gt;

&lt;p&gt;The current resource policy looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/development-team"
      },

      "Action": "execute-api:Invoke",
      "Resource": "arn:aws:execute-api:eu-west-1:123456789012:p61xuhn9cd"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In essence, the policy allows one of your development teams to invoke all methods of the API resource. The development team has a role aptly named  &lt;code&gt;development-team&lt;/code&gt;. This role exists in an AWS account with ID &lt;code&gt;123456789012&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Your organization is using Terraform to set up all your infrastructure. You keep all infrastructure code in a git repository.&lt;/p&gt;

&lt;p&gt;The current Terraform configuration for the API Gateway and its resource policy uses the following data source as a reference to the IAM role of the development team:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data "aws_iam_role" "development_team" {
  name = "development-team"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The development team is working on a new version of their application and infrastructure. The team is not aware of how their infrastructure is referenced in other parts of the organization, but they assume they should be able to update their own infrastructure without encountering any issues.&lt;/p&gt;

&lt;p&gt;As part of their new infrastructure setup they will change the name of their IAM role from &lt;code&gt;development-team&lt;/code&gt; to &lt;code&gt;development-team-a&lt;/code&gt; to better reflect their team name. They will also delete the old role named &lt;code&gt;development-team&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The development team performs these changes without first checking with you and your colleagues in the platform team.&lt;/p&gt;

&lt;p&gt;Shortly after the development team has performed their changes you notice a sudden increase in "403 Forbidden" responses in the API Gateway.&lt;/p&gt;

&lt;p&gt;After some troubleshooting you discover that there is a new role named &lt;code&gt;development-team-a&lt;/code&gt; that is trying to use the API. You contact the team who informs you of the changes they have made, and you enlighten them on the current issue you are seeing.&lt;/p&gt;

&lt;p&gt;The development team quickly rolls their change back, switching the name of the IAM role back to the original name of &lt;code&gt;development-team&lt;/code&gt; and recreates the role.&lt;/p&gt;

&lt;p&gt;You assume that the issue has been resolved since the original IAM role is now back. However, you notice that the rate of 403 responses stays steady even after the development team rolled back their change.&lt;/p&gt;

&lt;p&gt;You wonder what is going on, and decide to inspect API Gateway's resource policy. You discover the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "AROAZE64MWFAASURXM4E6"
      },
      "Action": "execute-api:Invoke",
      "Resource": "arn:aws:execute-api:eu-west-1:123456789012:p61xuhn9cd"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The policy does not look at all like what you expected. Instead of listing the IAM role in the resource policy there is now a random ID &lt;code&gt;AROAZE64MWFAASURXM4E6&lt;/code&gt;. Where does this ID come from?&lt;/p&gt;

&lt;p&gt;You look at the Terraform configuration for the API Gateway resource policy and see that it looks correct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data "aws_iam_role" "development_team" {
  name = "development-team"
}

data "aws_iam_policy_document" "test" {
  statement {
   effect = "Allow"
    principals {
      type = "AWS"
      identifiers = [
        data.aws_iam_role.development_team.arn,
      ]
    }
    # parts of the code left out for brevity
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;aws_iam_policy_document&lt;/code&gt; is correctly referencing the &lt;code&gt;aws_iam_role&lt;/code&gt; data source. The data source is correctly referencing a role named &lt;code&gt;development-team&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In a desperate attempt at fixing the issue you apply the Terraform configuration again to bring the infrastructure back to the desired state. The output from &lt;code&gt;terraform plan&lt;/code&gt; seems to indicate that the resource policy will be changed back to a working state:&lt;/p&gt;

&lt;p&gt;Terraform will perform the following actions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # aws_api_gateway_rest_api_policy.test will be updated in-place
  ~ resource "aws_api_gateway_rest_api_policy" "test" {
        id          = "p61xuhn9cd"
      ~ policy      = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Principal = {
                          ~ AWS = "AROAZE64MWFAASURXM4E6" -&amp;gt; "arn:aws:iam::123456789012:role/development-team"
                        }
                        # (3 unchanged attributes hidden)
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (1 unchanged attribute hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Specifically, the random ID &lt;code&gt;AROAZE64MWFAASURXM4E6&lt;/code&gt; will be replaced by &lt;code&gt;arn:aws:iam::123456789012:role/development-team&lt;/code&gt; as you expect.&lt;/p&gt;

&lt;p&gt;You run &lt;code&gt;terraform apply&lt;/code&gt;  and hope that the issue will be resolved.&lt;/p&gt;

&lt;p&gt;The change is applied and Terraform reports success. However, the 403 errors stay at the same alarming rate. Terraform has not updated the resource policy!&lt;/p&gt;

&lt;p&gt;You panic.&lt;/p&gt;

&lt;p&gt;You run another terraform apply to see what the current state of your infrastructure is. You discover that the plan looks exactly like the previous plan. You have discovered what appears to be a bug in the AWS provider, and you are not sure how to proceed.&lt;/p&gt;

&lt;p&gt;After an emergency meeting with the development team you decide to let the development team update their IAM role name to the new name of &lt;code&gt;development-team-a&lt;/code&gt;, and you update your resource policy to accommodate these changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data "aws_iam_role" "development_team" {
  # you update the name in this data source
  name = "development-team-a"
}

data "aws_iam_policy_document" "test" {
  statement {
    effect = "Allow"
    principals {
      type = "AWS"
      identifiers = [
        # the reference stays the same
        data.aws_iam_role.development_team.arn,
      ]
    }
    # parts of the code left out for brevity
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output from &lt;code&gt;terraform plan&lt;/code&gt;  once again indicates that the desired change will be performed:&lt;/p&gt;

&lt;p&gt;Terraform will perform the following actions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # aws_api_gateway_rest_api_policy.test will be updated in-place
  ~ resource "aws_api_gateway_rest_api_policy" "test" {
        id          = "p61xuhn9cd"
      ~ policy      = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Principal = {
                          ~ AWS = "AROAZE64MWFAASURXM4E6" -&amp;gt; "arn:aws:iam::629138043200:role/development-team-a"
                        }
                        # (3 unchanged attributes hidden)
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (1 unchanged attribute hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The random ID &lt;code&gt;AROAZE64MWFAASURXM4E6&lt;/code&gt; value will now be replaced by &lt;code&gt;arn:aws:iam::123456789012:role/development-team-a&lt;/code&gt; . You are not hopeful, but you apply the change anyway.&lt;/p&gt;

&lt;p&gt;The errors disappear! It seems like this time Terraform performed the change.&lt;/p&gt;

&lt;p&gt;You notice that the API Gateway resource policy looks better this time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/development-team-a"
      },
      "Action": "execute-api:Invoke",
      "Resource": "arn:aws:execute-api:eu-west-1:123456789012:p61xuhn9cd"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You and the rest of the platform engineering team set up a post mortem meeting together with the development team to discuss how you can avoid issues like this in the future.&lt;/p&gt;

&lt;p&gt;The scenario described above can, and has, happened.&lt;/p&gt;

&lt;p&gt;Each principal in AWS has a unique principal ID, an example of such an ID is &lt;code&gt;AROAZE64MWFAASURXM4E6&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Destroying an IAM role and creating a new role with the same name might seem like a safe thing to do, but it is not. The new IAM role has a new principal ID that does not match the original IAM role. There are a few places where this distinction is important, and one of them is in the API Gateway resource policy.&lt;/p&gt;

&lt;p&gt;What could the platform and development teams have done to avoid this issue? There are a number of things that could have been done:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Knowledge&lt;/strong&gt;: knowing about principal IDs and how resource policies behave could have prompted the development team to think one step further before applying their changes. Doing this successfully requires skill, communication and a bit of luck.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rearchitect your Terraform configurations&lt;/strong&gt;: currently the platform team uses data sources to read data (e.g. IAM role ARN) from development teams. This is a hidden dependency between different Terraform configurations, and it requires certain attributes of resources to stay the same. You could bring related parts into a single Terraform configuration and make sure they are always updated together. This might not be feasible for large distributed pieces of infrastructure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Discover dependencies&lt;/strong&gt;: if you have a way to discover dependencies between your Terraform configurations you could automate the process of discovery and inform of any potential issues a change in one Terraform configuration could mean in a different Terraform configuration. This process could be included in your CI/CD systems, pull-requests, and more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of the three options discussed above, the third option is the most reasonable in all situations. It does not require you to refactor all of your Terraform configurations into one large mono-infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best practices for AWS IAM
&lt;/h2&gt;

&lt;p&gt;There are a number of best practices around AWS IAM that you should implement. &lt;/p&gt;

&lt;h3&gt;
  
  
  Use the principle of least privilege
&lt;/h3&gt;

&lt;p&gt;When writing IAM policies for your entities, use the principle of least privilege. This means that you should assign the permissions that an entity needs to perform its job, but no more. A role that only needs to read blobs in an S3 bucket does not need to have full administrator access.&lt;/p&gt;

&lt;p&gt;You can restrict policies both in terms of the permissions you assign to an entity, and in terms of which resources the permissions apply to. You can also take it one step further to use conditions for when the permissions are valid.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use multi-factor authentication
&lt;/h3&gt;

&lt;p&gt;Use multi-factor authentication (MFA) for all your human user accounts on AWS. The benefit is that even if the user's password is leaked, it will not be enough to get access to the account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Secure the AWS root account
&lt;/h3&gt;

&lt;p&gt;The AWS root account should only be used for initial setup of the AWS account. As with any other user on AWS, enable MFA. You could use a physical MFA device (e.g. a Yubi key) that you store in a secure location.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use roles instead of users
&lt;/h3&gt;

&lt;p&gt;If possible, use IAM roles instead of IAM users. Roles use temporary security credentials by default which minimizes risks of leaked credentials. You can assign roles to your applications and services running on AWS and assign them the permissions they need.&lt;/p&gt;

&lt;p&gt;For your normal users, you can enable SSO sign-in and connect signed-in users to roles instead of IAM user accounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Audit IAM activity
&lt;/h3&gt;

&lt;p&gt;You should enable CloudTrail logs for your account and set up alerts for unusual events. You should alert for any activity performed by the root user account to make sure you are aware when this account is used.&lt;/p&gt;

&lt;h3&gt;
  
  
  Educate your organization on security best practices
&lt;/h3&gt;

&lt;p&gt;IAM security is paramount for your cloud environment. You should educate your organization on how to use IAM and to follow best practices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shift security left
&lt;/h3&gt;

&lt;p&gt;A general best practice is to shift-security left. Use IAM policies, service control policies (SCPs) and governance tools such as AWS IAM Access Analyzer to secure your environment. Perform a security analysis of each change you introduce in your environment. Integrate security features into your complete AWS environment and beyond.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;AWS Identity and Access Management (IAM) is a central service on AWS.&lt;/p&gt;

&lt;p&gt;Two important concepts of IAM include principals (users, groups, roles) and policies (permissions). Policies control what is allowed or denied in your environment, and these policies control what your principals can do in your AWS accounts.&lt;/p&gt;

&lt;p&gt;Given the centrality of IAM it is clear that this is a sensitive part of your infrastructure, where misconfigurations can lead to a complete stop in your production environment.&lt;/p&gt;

&lt;p&gt;In this blog post we followed a scenario where parts of a microservices architecture experienced an issue due to a broken policy from an innocent change of an IAM role.&lt;/p&gt;

&lt;p&gt;The infrastructure broke because each IAM principal has a principal ID that is unique. Recreating an IAM role with the same name still creates a principal with a new unique ID. An innocent change like that can break references to the role in unexpected ways that are hard to fix.&lt;/p&gt;

&lt;p&gt;Changes like the one highlighted in the scenario are common, and it is critical to understand what consequences your infrastructure changes can have.&lt;/p&gt;

&lt;p&gt;Anyshift can help you catch these types of mistakes. To get started visit anyshift.io and sign up for a free account.&lt;/p&gt;

</description>
      <category>iam</category>
      <category>aws</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>How we handle Terraform downstream dependencies without additional frameworks</title>
      <dc:creator>Roxane Fischer</dc:creator>
      <pubDate>Fri, 06 Dec 2024 14:27:50 +0000</pubDate>
      <link>https://dev.to/roxane_fischer_79570c1b5b/how-we-handle-terraform-downstream-dependencies-without-additional-frameworks-1c3o</link>
      <guid>https://dev.to/roxane_fischer_79570c1b5b/how-we-handle-terraform-downstream-dependencies-without-additional-frameworks-1c3o</guid>
      <description>&lt;p&gt;Hi, I’m the founder of Anyshift. We’ve developed a solution to handle Terraform downstream dependencies across mono and multi-repositories without relying on additional frameworks. Instead, we leverage the rich data in &lt;strong&gt;Terraform State Files&lt;/strong&gt; and a graph-based approach to solve these challenges. Here’s how we did it.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;1. The Challenges We Wanted to Solve&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Managing Terraform dependencies often involves three key challenges:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hardcoded values&lt;/strong&gt;: These make configurations brittle and difficult to scale.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote state dependencies&lt;/strong&gt;: Keeping track of changes across multiple states can be error-prone.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intricate modules&lt;/strong&gt;: Handling public and private modules across repositories adds complexity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We realized that the data needed to address these issues was already available in &lt;strong&gt;Terraform State Files&lt;/strong&gt;, enabling us to manage dependencies without introducing additional frameworks.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;2. Key Principles Behind Our Approach&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Our approach was guided by three core principles:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.1 Infrastructure is a Graph&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Infrastructure is inherently interconnected. Using &lt;strong&gt;Neo4j&lt;/strong&gt;, a graph database, we modeled the relationships between resources, modules, and states.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.2 All Data Is in the Cloud and Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;By parsing Terraform code and state files, we could surface the complete chain of dependencies without adding unnecessary overhead.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.3 Build a Digital Twin of Your Infrastructure&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We created a "digital twin" that combines information from Terraform code, state files, and the cloud. This unified view allowed us to catch and prevent issues early.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;3. Our Framework-Free Solution&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Our solution works through two key steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a digital twin of the infrastructure&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A graph captures the relationships between IaC code and deployed cloud resources.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Query the graph for every PR&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Using &lt;strong&gt;Cypher&lt;/strong&gt;, Neo4j’s query language, we retrieve downstream dependencies and surface the impact of changes directly in the PR.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3.1 Leveraging Terraform State Files&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Terraform state files contain more than just the representation of deployed infrastructure. They include rich metadata such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource types&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unique identifiers&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships between modules and their resources&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By parsing these state files, we extracted key insights across repositories and environments. They act as a bridge between &lt;strong&gt;code-defined intentions&lt;/strong&gt; and &lt;strong&gt;cloud-deployed realities.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3.2 Building the Cloud-to-Code Graph with Neo4j&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We structured our graph as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nodes&lt;/strong&gt;: Representing infrastructure resources like EC2 instances, VPCs, or Security Groups.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships&lt;/strong&gt;: Capturing interactions like "CONNECTED_TO" or "IN_REGION."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, an EC2 instance (node) may be connected to a Security Group (another node). This graph provided a precise and actionable representation of infrastructure.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3.3 Reconciling Data Across Sources&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To ensure accuracy, we reconciled:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Terraform code&lt;/strong&gt;: Capturing intended resource configurations.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terraform state files&lt;/strong&gt;: Reflecting deployed resources.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud environments&lt;/strong&gt;: Verifying the current state of resources.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We labeled nodes to differentiate between these sources (e.g., &lt;code&gt;TF_CODE&lt;/code&gt;, &lt;code&gt;TF_STATE&lt;/code&gt;) to provide a clear view of &lt;strong&gt;intent vs. reality.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;4. Querying the Graph to Manage Dependencies&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We used the graph to proactively manage downstream dependencies during pull requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.1 Step 1: Make a Change&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For example, expanding the CIDR range of a VPC.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.2 Step 2: Query the Graph&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use Cypher to identify downstream resources affected by the change.&lt;br&gt;&lt;br&gt;
   Example: Expanding the CIDR range may impact &lt;strong&gt;2 ECS instances&lt;/strong&gt; and &lt;strong&gt;1 security group.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.3 Step 3: Surface Results in the PR&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Display the affected resources directly in the pull request, enabling proactive resolution of conflicts before merging.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;5. Current Limitations&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While the solution has been effective, there are a few limitations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cypher Query Flexibility&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The power of the solution depends on how well we define the queries. We’re continually refining them to handle more use cases.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Terraform-Specific&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Currently, the solution works only with Terraform. However, the concept could potentially be extended to other IaC frameworks like &lt;strong&gt;Pulumi&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;By leveraging &lt;strong&gt;Terraform State Files&lt;/strong&gt; and &lt;strong&gt;Neo4j&lt;/strong&gt;, we’ve created a robust, framework-free solution for managing Terraform downstream dependencies. This approach bridges the gap between &lt;strong&gt;code-defined intentions&lt;/strong&gt; and &lt;strong&gt;cloud-deployed realities&lt;/strong&gt;, enabling teams to catch and resolve issues earlier in the development process.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>infrastructureascode</category>
      <category>aws</category>
    </item>
    <item>
      <title>DevOps Dallas Day- 5 Reasons You're Struggling to Debug Your Infrastructure in Under an Hour</title>
      <dc:creator>Roxane Fischer</dc:creator>
      <pubDate>Wed, 23 Oct 2024 09:36:42 +0000</pubDate>
      <link>https://dev.to/roxane_fischer_79570c1b5b/devops-dallas-day-5-reasons-youre-struggling-to-debug-your-infrastructure-in-under-an-hour-c5c</link>
      <guid>https://dev.to/roxane_fischer_79570c1b5b/devops-dallas-day-5-reasons-youre-struggling-to-debug-your-infrastructure-in-under-an-hour-c5c</guid>
      <description>&lt;h2&gt;
  
  
  5 Reasons You're Struggling to Debug Your Infrastructure in Under an Hour
&lt;/h2&gt;

&lt;p&gt;Hey! 👋&lt;/p&gt;

&lt;p&gt;At DevOps Dallas Day, I shared &lt;em&gt;5 Reasons You're Struggling to Debug Your Infrastructure in Under 10 Minutes&lt;/em&gt;. We dug into common issues like misconfigured Terraform files and tricky AWS IAM policies. If you're interested, here's the replay  :)&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1VDr0RJErjw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>infrastructureascode</category>
      <category>aws</category>
    </item>
    <item>
      <title>Navigating AI in your Infrastructure: Do's, Don'ts, and why it matters</title>
      <dc:creator>Roxane Fischer</dc:creator>
      <pubDate>Tue, 15 Oct 2024 10:55:01 +0000</pubDate>
      <link>https://dev.to/roxane_fischer_79570c1b5b/navigating-ai-in-your-infrastructure-dos-donts-and-why-it-matters-2gfa</link>
      <guid>https://dev.to/roxane_fischer_79570c1b5b/navigating-ai-in-your-infrastructure-dos-donts-and-why-it-matters-2gfa</guid>
      <description>&lt;p&gt;&lt;a href="https://www.anyshift.io/blog/navigating-ai-in-your-infrastructure-dos-don-ts-and-why-it-matters" rel="noopener noreferrer"&gt;Original Post&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;GenAI is everywhere.  Dozens of "AI SRE" or "DevOps copilot" companies have recently popped up from the VC world. But very often, the cool and exciting demos don’t work the same way in production. And even worse, some generated content might open the door to security risks.  Here's "The Dos and Don'ts with AI and Your Infra Nowadays" and why it matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. IaC Code Generation is not there yet...
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1 Don't blindly generate your IaC code
&lt;/h3&gt;

&lt;p&gt;Code generation with AI is just amazing.  I practically use GPT (or cursor AI) everyday. But let's be real: IaC code generation isn't mature enough to be 100% trusted in prod.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2 First of all, how does GenAI work?
&lt;/h3&gt;

&lt;p&gt;At its core, a Large Language Model (LLM) like GPT-4 is a probability model. It works by encoding text—including code—into a latent space (imagine a high-dimensional space where similar pieces of text are closer together). Then it generates code by decoding from that space based on statistical probabilities. Essentially, it predicts the next word (or token) in a sequence by considering the context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Encoder&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Latent&lt;/span&gt; &lt;span class="nx"&gt;Space&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Decoder&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Generated&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;]&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="o"&gt;|&lt;/span&gt;
                    &lt;span class="o"&gt;|------------------------------|&lt;/span&gt;
                         &lt;span class="nx"&gt;Probability&lt;/span&gt; &lt;span class="nx"&gt;Distribution&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example with Python:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say the model has been trained extensively on Python code. If you prompt it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model predicts the next token based on probabilities learned during training. It knows that after &lt;code&gt;return&lt;/code&gt;, in the context of a function adding two numbers, the next likely tokens are &lt;code&gt;a + b&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So it generates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the step-by-step token prediction:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;def&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;add&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;,&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;b&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;):&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;\\n&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;return&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;+&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;b&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At each step, the model selects the most probable next token based on the context so far.&lt;/p&gt;

&lt;p&gt;Similarly, if you ask it to write a function to multiply two numbers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Write a function to multiply two numbers in Python."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generated Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, the model uses learned probabilities to generate each token, producing correct and functional code because it's seen lots of similar examples during training.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example with Terraform:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, suppose the model has seen very few examples of advanced Terraform configurations for AWS VPC peering. If you prompt it to generate a Terraform script for VPC peering with specific settings, it might produce incomplete or incorrect code because the latent space representation for this niche is sparse.&lt;/p&gt;

&lt;p&gt;Here's what you might get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Incomplete VPC Peering configuration
resource "aws_vpc_peering_connection" "peer" {
  peer_vpc_id = "vpc-12345678"
  vpc_id      = "vpc-87654321"
  # Missing auto_accept and tags
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What's missing or wrong:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Missing &lt;code&gt;auto_accept&lt;/code&gt; parameter:&lt;/strong&gt; Without this, the peering connection might not be established automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No tags or additional configurations:&lt;/strong&gt; Important metadata and route settings are absent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Potentially incorrect IDs:&lt;/strong&gt; Using placeholder VPC IDs without context can lead to errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In contrast, here's how a correct configuration might look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Correct VPC Peering configuration
resource "aws_vpc_peering_connection" "peer" {
  peer_vpc_id = aws_vpc.peer_vpc.id
  vpc_id      = aws_vpc.main_vpc.id
  auto_accept = true

  tags = {
    Name = "Main-to-Peer"
  }
}

resource "aws_route" "peer_route" {
  route_table_id            = aws_vpc.main_vpc.main_route_table_id
  destination_cidr_block    = aws_vpc.peer_vpc.cidr_block
  vpc_peering_connection_id = aws_vpc_peering_connection.peer.id
}

resource "aws_route" "main_route" {
  route_table_id            = aws_vpc.peer_vpc.main_route_table_id
  destination_cidr_block    = aws_vpc.main_vpc.cidr_block
  vpc_peering_connection_id = aws_vpc_peering_connection.peer.id
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the correct configuration includes route settings and proper references, which the AI might miss due to limited training data in this area.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.3 But here's the catch for code quality
&lt;/h3&gt;

&lt;p&gt;LLMs are only as good as the data they're trained on. Terraform and IaC tools are relatively new (about 10 years old). That means the dataset the model was trained on (mostly from GitHub) is sparse. But most of all, most companies don't put their infra code on GitHub for security reasons. So the encoding space for this kind of code is sparse, making it harder for the model to generalize.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another Angle:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine encoding two similar resources in Terraform. Due to the sparse data, when decoding, the model might mix things up, leave out critical parts, or extrapolate content from the original prompt (now, it’s more about framing the right question than coding the answer!) . It wouldn't have done that in a language like Python, where there's tons more data to learn from.&lt;/p&gt;

&lt;p&gt;As the saying goes, "garbage in, garbage out." In this case: "small dataset in, lower accuracy out."&lt;/p&gt;

&lt;h3&gt;
  
  
  1.4 Even worse, it can cause some security issues
&lt;/h3&gt;

&lt;p&gt;Let's recap. Most LLMs were trained on GitHub with a maximum of 10 years of data with very few open IaC repositories —and even worse, with repos that might contain potential attacks vectors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An attacker might have uploaded Terraform code with security flaws, like open security groups. The LLM, trained on this code, could generate similar insecure code for you.&lt;/p&gt;

&lt;p&gt;For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Insecure security group generated by AI
resource "aws_security_group" "bad_sg" {
  name        = "bad_sg"
  description = "Insecure security group"

  ingress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"] # Allows all inbound traffic from anywhere
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why this is dangerous:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Opens All Ports to the World:&lt;/strong&gt; This could expose your servers to attacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard to Spot if You're Not Careful:&lt;/strong&gt; If you trust the AI output blindly, you might miss this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it comes to your infra—the core of your cloud—such vulnerabilities are even more dangerous.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Nevertheless it's improving
&lt;/h2&gt;

&lt;p&gt;But things are getting better. Improvements, made day by day, let us hope than IaC code generation will considerably improve in the near future.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Fake GenAI Datasets for Training Newer Models
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2.1.1 Bigger Models Generating Synthetic Datasets for Smaller Models
&lt;/h3&gt;

&lt;p&gt;Big models can generate better outputs. We use them to create synthetic datasets to make the input data for smaller models "denser," so they perform better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using a big model to generate various secure Terraform configurations, filling in the gaps where real data is sparse. This helps the smaller models learn better patterns.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1.2 Positively biased datasets
&lt;/h3&gt;

&lt;p&gt;These are datasets improved on purpose by curating and including only best practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Filtering Out Bad Examples:&lt;/strong&gt; Removing insecure or bad code from the training data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adding Good Examples:&lt;/strong&gt; Including well-written, secure code snippets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The model learns from higher-quality data, reducing the chance of generating insecure or low-quality code.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1.3 The future, contextual AI?
&lt;/h3&gt;

&lt;p&gt;While current AI models have limitations, the future looks promising with the development of what we can call &lt;strong&gt;Contextual AI&lt;/strong&gt;. This approach involves models that understand and incorporate the specific context of your environment. For information retrieval, you can see it as an equivalent to RAG (Retrieval-Augmented Generation).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Highlights:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Integration with your infra:&lt;/strong&gt; Future AI could tailor code to your specific setup by accessing real-time information about your infrastructure and organizational standards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy-Aware Generation:&lt;/strong&gt; By understanding your security policies and compliance requirements, Contextual AI can generate IaC that adheres to your rules, reducing the risk of insecure configurations.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. "Synthesis AI" vs "Generative AI"
&lt;/h2&gt;

&lt;p&gt;We've just seen that code generation can be tricky (even if the next 5 to 1 year may surprise us a lot).&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 The notion of Synthesis AI
&lt;/h3&gt;

&lt;p&gt;A super cool article from A16Z (&lt;a href="https://a16z.com/for-b2b-generative-ai-apps-is-less-more/" rel="noopener noreferrer"&gt;link&lt;/a&gt;) introduced the notion of "Synthesis AI." According to them, we're moving from Wave 1 of AI that generates more content to Wave 2 of AI that helps us by synthesizing information—showing us less but more meaningful content.&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%2Fwsp1aeqjpbyxwv5pl0ze.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%2Fwsp1aeqjpbyxwv5pl0ze.png" alt="AI pandora box" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quality Over Quantity:&lt;/strong&gt; In B2B settings, we care about making better decisions faster, not wading through more content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI as an Assistant:&lt;/strong&gt; Helps us understand complex info, like logs or infra topology, rather than generating new code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.2 Practical applications
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.2.1 Reading logs
&lt;/h3&gt;

&lt;p&gt;“Synthesis AI” is already revolutionizing how we read and interpret logs. By highlighting critical information and patterns, it helps us quickly identify issues and understand system behavior without wading through endless lines of log data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proactive Issue Resolution:&lt;/strong&gt; By automatically detecting anomalies and performance issues, teams can address problems before they impact users, reducing downtime and maintaining service reliability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency Gains:&lt;/strong&gt; AI-powered log analysis minimizes the time engineers spend manually parsing logs, allowing them to focus on more strategic initiatives.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.2.2 Understanding your infra's topology
&lt;/h3&gt;

&lt;p&gt;When it comes to grasping your infrastructure's topology, the challenge isn't about the number of lines of code but understanding the broader implications of your configurations. It's about how components like VPCs are set up and how they interact. The complexity lies in the deep understanding required to navigate a volatile or sensitive environment—where even a small misconfiguration can lead to significant issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.3 The importance of complementary, deterministic approaches
&lt;/h3&gt;

&lt;p&gt;While AI tools like “Synthesis AI” offer valuable assistance, it's crucial to complement them with deterministic methods, such as accurately mapping your infrastructure. These approaches ensure that your infrastructure is intentionally designed and well-understood, reducing the risk of misconfigurations and security vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Mapping Is Essential:&lt;/strong&gt; Structured maps of your infrastructure enable better decision-making and highlight potential issues before they become critical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoiding Oversimplification:&lt;/strong&gt; Relying solely on AI can oversimplify complex systems. Deterministic methods maintain the necessary depth of understanding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Accessibility and Structure:&lt;/strong&gt; Making infrastructure data queryable in a structured way allows for more effective analysis and management&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the end, even if IaC code generation isn't quite there yet, improvements are on the horizon. We must remain cautious, always reviewing AI-generated code and relying on deterministic tools to add that extra layer of security. Use AI as a tool to assist you, not replace you—especially when it comes to your infra.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>ai</category>
      <category>infrastructureascode</category>
    </item>
  </channel>
</rss>
