How to Configure AWS Cli Create Instance Profile
You use the aws cli create instance profile action to pass an IAM role to EC2. You set it up by making a profile, adding one role, and linking it to a server. Cloud servers need permissions to read storage buckets, write logs, or call other cloud services. Hardcoding static keys on a disk creates a big security risk for your team. Anyone who reads the disk can steal those static keys and use them anywhere. An instance profile solves this problem by handing out short-term keys to the server. Whe
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You use the aws cli create instance profile action to pass an IAM role to EC2. You set it up by making a profile, adding one role, and linking it to a server.
Cloud servers need permissions to read storage buckets, write logs, or call other cloud services. Hardcoding static keys on a disk creates a big security risk for your team. Anyone who reads the disk can steal those static keys and use them anywhere. An instance profile solves this problem by handing out short-term keys to the server. When you run a command in the web console, the tool creates this profile behind the scenes. When you use the command line tool, you must create the profile step by step.
How the aws cli create instance profile workflow works
An instance profile acts like a box that holds one IAM role for a virtual server. A role holds the rules, while the profile lets the server use that role at boot time. When you use the command line, you must build the profile and the role as separate items. First, your team sets up the IAM role with a trust policy for the compute service. That trust policy says that only cloud servers can put on the role. Second, you run the aws cli create instance profile step to make the empty container. Third, you link your IAM role into that new container using an add role action. Each profile can hold only one IAM role at any given time. Fourth, you attach the finished profile to a new or running virtual machine. Once linked, the server asks a local metadata service for temporary keys when an app runs. The metadata service checks the profile and hands back keys that expire on a set schedule.
Safe defaults and least privilege rules
Setting up a profile is only safe if you lock down the role inside it. Many teams attach broad admin policies to get an app running fast during early tests. If an attacker breaks into that web app, they gain full control over the cloud account. Instead, write a tight policy that lists only the exact actions the server must run. You should also name the profile and the role with the exact same string. Matching names keep your setup clean and help your team avoid confusion during audits. In the web console, the system makes the names match by default, so follow that pattern. You must also enforce version two of the instance metadata service on every single server. Version two requires a session token before an app can read the role keys. This simple rule stops common web attacks from stealing cloud keys from the metadata endpoint.
Checking setups and limits of static server roles
After you link a profile to a server, you should check that the setup works right. You can query the IAM service from the command line to list the attached roles. Check your cloud audit logs to see when the server assumes the role and runs actions. Still, an instance profile only controls how a server talks to cloud APIs. It does not control what happens when an engineer logs into the server to fix a bug. Once a person opens a shell session on that machine, they inherit the server role. Every engineer on that box shares the same permissions and leaves the same role name in logs. Static server roles also cannot inspect database queries or mask sensitive fields like emails or card numbers. If the server role can read a database, anyone on the box can pull raw records. To close this gap, teams need runtime controls that check human identity and inspect live commands.
AWS Config Rules + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
What is the difference between an IAM role and an instance profile?
An IAM role holds a set of permission rules and a trust policy. An instance profile is a wrapper that passes that single role to an EC2 server.
Why does my new role not show up in the EC2 launch list?
When you create a role via the CLI, it has no instance profile by default. You must create the profile and add the role to it before EC2 can see it.
Can I attach more than one IAM role to a single instance profile?
No, an instance profile can hold only one IAM role at a time. If your server needs two sets of rules, combine those policies into one single role.
Related guides
In this post