Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue report]Misuse of iaminstanceprofile in aws_ec2_iaminstance.json due to missing EC2InstanceProfile object #1365

Open
xiaoen-liu opened this issue Oct 2, 2024 · 4 comments
Labels
analysis Regarding ways to better understand and present data in the graph AWS Related to cartography's AWS module bug Something isn't working schema Graph data schema issues

Comments

@xiaoen-liu
Copy link

Title: Misuse of iaminstanceprofile in aws_ec2_iaminstance.json due to missing EC2InstanceProfile object

Description:

In aws_ec2_iaminstance.json (found here), Cartography incorrectly assumes a direct connection between the iaminstanceprofile name and the IAM Role. This assumption is not accurate, as AWS uses IamInstanceProfile as a distinct resource that links to a single IAM Role.

The misuse happens because Cartography does not currently create a separate EC2InstanceProfile object, leading to incorrect modeling of the relationship between EC2 Instances and IAM Roles.

Expected behavior:

A separate EC2InstanceProfile object should be created and properly linked to EC2 Instances.
The relationship between the EC2InstanceProfile and its associated IAM Role should be accurately represented, avoiding the incorrect assumption about the name correlation.

[optional Relevant Links:]

here

@xiaoen-liu xiaoen-liu changed the title [feature request]Misuse of iaminstanceprofile in aws_ec2_iaminstance.json due to missing EC2InstanceProfile object [Issue report]Misuse of iaminstanceprofile in aws_ec2_iaminstance.json due to missing EC2InstanceProfile object Oct 2, 2024
@achantavy
Copy link
Contributor

@xiaoen-liu - Thanks for reporting, this is a valid issue.

To make sure I understand, the current model is

EC2 Instance ←→ IAM Role

but it should be this instead:

EC2 Instance ←→ IamInstanceProfile ←→ IAM Role

Is this right?

@achantavy achantavy added AWS Related to cartography's AWS module bug Something isn't working analysis Regarding ways to better understand and present data in the graph schema Graph data schema issues labels Oct 2, 2024
@xiaoen-liu
Copy link
Author

Yes, without having the IamInstanceProfile as a separate model, it's not possible to correctly establish the node relationships between EC2 Instances and IAM Roles.

@xiaoen-liu
Copy link
Author

I would like to further clarify the cause of this confusion. The creation of an AWS Instance Profile and the binding of an Instance Profile to an IAM Role are two separate API calls: IAM.Client.create_instance_profile and IAM.Client.add_role_to_instance_profile. These APIs do not require the instance profile name and the IAM role name to have any relationship.

However, the AWS Console design makes it appear as though the instance profile name and the IAM role name are identical, which leads to confusion. This issue becomes more pronounced when using Infrastructure as Code (IaC) tools like Terraform, CloudFormation, or CDK, where instance profile names and IAM role names are often completely different.

This discrepancy can cause significant issues in environments where IaC is used to manage AWS resources, making it important to properly model the distinction between instance profiles and IAM roles.

@chandanchowdhury
Copy link
Collaborator

From what I understand and also from looking at our tfstate files

aws_iam_instance_profile -(one-to-one)→ role

while

role -(one-to-many)→ aws_iam_instance_profile 

So not sure what the issue issue!

@xiaoen-liu Are you able to provide an example please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Regarding ways to better understand and present data in the graph AWS Related to cartography's AWS module bug Something isn't working schema Graph data schema issues
Projects
None yet
Development

No branches or pull requests

3 participants