<?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: uttamchaturvedi9</title>
    <description>The latest articles on DEV Community by uttamchaturvedi9 (@uttamchaturvedi9).</description>
    <link>https://dev.to/uttamchaturvedi9</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%2F597415%2F8ab12285-1dc0-4439-8f03-38c3ed016fd3.png</url>
      <title>DEV Community: uttamchaturvedi9</title>
      <link>https://dev.to/uttamchaturvedi9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uttamchaturvedi9"/>
    <language>en</language>
    <item>
      <title>IAC with Terraform</title>
      <dc:creator>uttamchaturvedi9</dc:creator>
      <pubDate>Wed, 20 Aug 2025 19:27:38 +0000</pubDate>
      <link>https://dev.to/uttamchaturvedi9/iac-with-terraform-555b</link>
      <guid>https://dev.to/uttamchaturvedi9/iac-with-terraform-555b</guid>
      <description>&lt;p&gt;Terraform is an open-source IaC (Infrastructure-as-Code) tool for configuring and deploying cloud infrastructure. It codifies infrastructure in configuration files that describe the desired state for your topology. Terraform allows you to use a consistent workflow over your infrastructure lifecycle, regardless of the resource provider. The infrastructure as code workflow lets your declaratively manage a variety of services and automate your changes to them, reducing the risk of human error through manual operations.&lt;/p&gt;

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

&lt;p&gt;IAC is crucial because it helps to speed deployment and release of software&lt;/p&gt;

&lt;p&gt;Terraforms support provide multi-cloud platforms like AWS, AZURE and Google etc..&lt;/p&gt;

&lt;p&gt;IAC assist to restrict user to delete resources accidentally&lt;/p&gt;

&lt;p&gt;Provide template to write code and use it many times&lt;/p&gt;

&lt;p&gt;Unified template also provide security&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workflows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In HCP Terraform, your resources are organized by workspaces, which contain your resource definitions, environment and input variables, and state files. A Terraform operation occurs within a workspace, and Terraform uses the configuration and state for that workspace to modify your infrastructure.&lt;/p&gt;

&lt;p&gt;HCP Terraform supports three workflows for your Terraform runs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The CLI-driven workflow, which uses Terraforms standard CLI tools to execute runs in HCP Terraform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The UI/Version Control System(VCS)-driven workflow, in which changes  pushed to version control repositories trigger runs in the associated workspace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The API-driven workflow, which allows you to create tooling to interact with the HCP Terraform API programmatically&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Init&lt;/strong&gt;: Validate working directory consisting of terraform config file. This is the first command to be executed after writing new file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validate&lt;/strong&gt;: Check for syntax and validate config file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plan&lt;/strong&gt;: Create execution plan&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apply&lt;/strong&gt;: Apply changes and execute command to create resources&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Destroy&lt;/strong&gt;: Remove terraform managed resources. It will ask for confirmation before removing resources&lt;/p&gt;

&lt;p&gt;In the below example we will deplyoing resource group using terraform modules with real world scenario&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Terraform Module Definition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Terraform module is a container for multiple resources that are used together.&lt;/p&gt;

&lt;p&gt;A module can be as simple as a single resource or as complex as a complete infrastructure stack.&lt;/p&gt;

&lt;p&gt;Modules provide a modular structure with a clear separation of concerns, making infrastructure easier to manage, reuse, and maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Deploying a Resource Group with Terraform Modules&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this example, we use Terraform modules to deploy a Resource Group.&lt;br&gt;
The project repository for the Resource Group creation is available here:&lt;br&gt;
&lt;a href="https://github.com/uttamchaturvedi9/terraformforcommunity" rel="noopener noreferrer"&gt;https://github.com/uttamchaturvedi9/terraformforcommunity&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;├── main.tf                    # Main Terraform configuration&lt;br&gt;
├── variables.tf               # Variable definitions&lt;br&gt;
├── terraform.tfvars           # variable values&lt;br&gt;
├── modules/                   # Terraform modules&lt;br&gt;
│   └── resource-group/        # Resource Group module&lt;br&gt;
│       ├── main.tf           # Module main configuration&lt;br&gt;
│       ├── variables.tf      # Module variables&lt;br&gt;
│       └── outputs.tf        # Module outputs&lt;br&gt;
└── README.md                 # This file&lt;/p&gt;

&lt;p&gt;This repository demonstrates how to:&lt;/p&gt;

&lt;p&gt;Define a Terraform module for Resource Group creation.&lt;/p&gt;

&lt;p&gt;Use input variables for flexibility.&lt;/p&gt;

&lt;p&gt;Apply modular structure for better reusability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
Terraform, as an Infrastructure as Code (IAC) tool, allows infrastructure provisioning and management through declarative configuration files. By defining resources in reusable modules, teams achieve:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt;: Repeatable deployments across environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modularity&lt;/strong&gt; : Clear separation of concerns, making code reusable and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: Ability to orchestrate simple to complex infrastructure stacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Collaboration&lt;/strong&gt;: Version-controlled infrastructure code shared across teams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Using Terraform as IAC empowers organizations to manage infrastructure in the same way they manage application code. This approach reduces manual effort, minimizes errors, and accelerates delivery. With its modular design, state management, and provider ecosystem, Terraform provides a scalable, reliable, and automated way to orchestrate infrastructure, making it a cornerstone of modern DevOps practices.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>SAS Token - Secure way</title>
      <dc:creator>uttamchaturvedi9</dc:creator>
      <pubDate>Sun, 10 Aug 2025 21:05:36 +0000</pubDate>
      <link>https://dev.to/uttamchaturvedi9/sas-token-secure-way-1kic</link>
      <guid>https://dev.to/uttamchaturvedi9/sas-token-secure-way-1kic</guid>
      <description>&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%2Ff0hl0qun2p89ne252vmv.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%2Ff0hl0qun2p89ne252vmv.png" alt=" " width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;br&gt;
An HTML file stored in Azure Blob Storage was not accessible when opened as a direct link.&lt;/p&gt;

&lt;p&gt;The following issues were encountered:&lt;br&gt;
Without authentication, the blob was private and returned Authorization errors.&lt;br&gt;
When accessed via a generated SAS token, the browser attempted to download the file instead of rendering it as an HTML page.&lt;br&gt;
Direct access using a blob endpoint was not possible for users inside the network without special permissions.&lt;br&gt;
The requirement was to make the file viewable in a browser as a web page via a shareable link while still controlling access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The soultion is SAS tokens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After investigation, the following steps were taken to make the file accessible through a SAS token and open correctly in the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate a SAS Token for the Blob&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Shared Access Signature (SAS) token grants time-limited and permission-scoped access to a specific blob without exposing the storage account key.&lt;/p&gt;

&lt;p&gt;Steps (Azure Portal):&lt;/p&gt;

&lt;p&gt;_Navigate to the Azure Storage Account in the Azure Portal.&lt;br&gt;
Go to Containers → open the target container (e.g., invetoryreport).&lt;br&gt;
Locate and click on the HTML file (e.g., /stockdata/invetoryreport.html).&lt;br&gt;
Click Generate SAS at the top.&lt;br&gt;
Configure:&lt;br&gt;
Permissions: Read (r)&lt;br&gt;
Start time: A few minutes earlier than the current time (to avoid clock skew issues)&lt;br&gt;
Expiry time: As per requirement (e.g., 1 day or 1 week)&lt;br&gt;
Allowed protocol: HTTPS&lt;br&gt;
(Optional) Allowed IP addresses: Specify if restricting to certain networks&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click Generate SAS token and URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the Blob SAS URL provided. This URL contains the file path and SAS token parameters._&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set Correct Content-Type for the Blob&lt;br&gt;
By default, blobs may be served with the application/octet-stream MIME type, which forces browsers to download them. To make an HTML file render in a browser, the Content-Type must be set to text/html.&lt;/p&gt;

&lt;p&gt;Steps (Azure Portal):&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the blob’s details page, click Properties.&lt;br&gt;
Locate the Content-Type field.&lt;br&gt;
Change the value to text/html&lt;br&gt;
Save the changes.&lt;/em&gt;&lt;br&gt;
Congratulations!!!! . Now you can access file directly in browser&lt;/p&gt;

&lt;p&gt;Advantages of SAS Tokens&lt;/p&gt;

&lt;p&gt;Granular Access Control You can grant access to specific resources (containers, blobs, queues, tables, files) without giving full account keys. Permissions can be fine-tuned (read, write, delete, list, etc.).&lt;br&gt;
Time-Bound AccessTokens can expire automatically, reducing the risk of long-term exposure.&lt;br&gt;
No Need to Share Account Keys Account keys give full access; a SAS token limits scope and reduces potential damage if compromised.&lt;br&gt;
Temporary &amp;amp; Revocable You can revoke access by regenerating the storage account keys or changing stored policies.&lt;br&gt;
Flexible Delivery Tokens can be passed via URLs, making them easy to use in applications, scripts, and APIs without extra authentication steps.&lt;br&gt;
Disadvantages of SAS Tokens&lt;br&gt;
Security Risk if Leaked Anyone with the SAS URL has the permissions until it expires — so tokens must be protected like passwords.&lt;br&gt;
Difficult to Revoke Before Expiry For ad hoc SAS tokens (not tied to a stored access policy), you can’t revoke them without rotating the storage account key.&lt;br&gt;
Potential for Over-Permissioning If not configured carefully, a token might allow more actions than intended.&lt;br&gt;
Expiration Management Short expiry improves security but can cause operational issues if the token expires mid-process; long expiry increases risk if leaked.&lt;br&gt;
Logging Limitations You can see when storage is accessed, but you can’t easily trace the identity of the person using the token — it’s just whoever has it.&lt;/p&gt;

&lt;p&gt;💡 Best Practice:&lt;/p&gt;

&lt;p&gt;Use stored access policies where possible — they let you revoke a SAS without touching account keys.&lt;br&gt;
Always use HTTPS to prevent token sniffing.&lt;br&gt;
Keep SAS lifetimes short and permissions minimal.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Azure Service Principle</title>
      <dc:creator>uttamchaturvedi9</dc:creator>
      <pubDate>Thu, 15 May 2025 18:29:45 +0000</pubDate>
      <link>https://dev.to/uttamchaturvedi9/azure-service-principle-2f13</link>
      <guid>https://dev.to/uttamchaturvedi9/azure-service-principle-2f13</guid>
      <description>&lt;p&gt;When I first encountered the term “Service Principal”, I was completely confused.&lt;br&gt;
Was it a user? Was it an app? Was it a login account?&lt;br&gt;
And why did it need its own password or secret key?&lt;/p&gt;

&lt;p&gt;If you’re getting started with cloud infrastructure, especially in Azure, the concept of a Service Principal can feel vague and overly abstract.&lt;/p&gt;

&lt;p&gt;You’re not alone — many professionals, especially those coming from traditional development or sysadmin backgrounds, struggle to understand:&lt;/p&gt;

&lt;p&gt;What exactly is a Service Principal?&lt;/p&gt;

&lt;p&gt;When and why should you use one?&lt;/p&gt;

&lt;p&gt;In this post, I’ll break it down in plain language, using real-world example and code snippets— so by the end, you’ll never be confused by the term again.&lt;/p&gt;

&lt;p&gt;Service Principal is like a user account for apps or services that need to access Azure resources. For example in order to login in the system user need user name and password, similarly its kind of user name and password for the app to access resource in azure&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Very Simple Definition:&lt;/strong&gt;&lt;br&gt;
A service principal is a special account that lets an app or automation tool sign in to Azure and do things, like start a virtual machine or deploy code — but only what you allow it to do.&lt;br&gt;
It’s not a person, but it has its own ID and password (called a client ID and secret), and you can control what it’s allowed to access using roles and permissions.&lt;/p&gt;

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

&lt;p&gt;1.When You Register an Application in Azure AD&lt;br&gt;
• Scenario: You create an app registration (e.g., for a web app, API, or daemon service).&lt;br&gt;
• Result: Azure automatically creates a corresponding Service Principal in your tenant.&lt;br&gt;
• Purpose: The app can then authenticate and access resources based on the permissions you assign to the service principal.&lt;br&gt;
App Registration = Identity&lt;br&gt;
Service Principal = Role-playing identity inside a tenant&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When You Create an Azure Resource That Needs to Access Other Resources
Examples:
• Azure Kubernetes Service (AKS)
• Azure App Service with managed identity
. Azure Data Factory with linked services
• Result: Azure automatically creates a Managed Identity, which is essentially a Service Principal under the hood.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;System-assigned managed identity is tightly coupled with the resource and gets deleted if the resource is deleted.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When Using Azure DevOps Service Connections
• Scenario: You create a Service Connection in Azure DevOps to deploy resources to Azure.
• Result: Azure DevOps automatically creates a service principal and assigns it the required permissions (e.g., Contributor role).
It’s best practice to regularly audit these service principals and rotate secrets if not using managed identity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a Service Principal with permissions to access a specific Azure subscription or resource group.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;

&lt;p&gt;az ad sp create-for-rbac — name “terraform-deployer” — role=”Contributor” — scopes=”/subscriptions//resourceGroups/”&lt;/p&gt;

&lt;p&gt;This command outputs:json&lt;br&gt;
CopyEdit&lt;br&gt;
{&lt;br&gt;
“appId”: “xxxxx-xxxx-xxxx-xxxx”,&lt;br&gt;
“displayName”: “terraform-deployer”,&lt;br&gt;
“password”: “xxxxxxx”,&lt;br&gt;
“tenant”: “xxxxx-xxxxx”&lt;br&gt;
}&lt;br&gt;
These credentials are saved as secrets in your CI/CD pipeline.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure Terraform with the Service Principal:
In your pipeline or terminal, set these environment variables:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;bash&lt;br&gt;
CopyEdit&lt;br&gt;
export ARM_CLIENT_ID=xxxxx-xxxx&lt;br&gt;
export ARM_CLIENT_SECRET=xxxxxxx&lt;br&gt;
export ARM_SUBSCRIPTION_ID=xxxxx-xxxx&lt;br&gt;
export ARM_TENANT_ID=xxxxx-xxxx&lt;br&gt;
Now, Terraform can authenticate to Azure securely and automatically using the Service Principal&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
Using a Service Principal (either directly or via Managed Identity) is a secure and scalable way to let your Azure applications access other Azure resources — like Key Vault, Storage, or SQL — without using hardcoded credentials. This approach enhances security, supports automation, and aligns with DevSecOps best practices.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
