IAM policies should be attached only to groups or roles to promote centralized permission management and reduce the risk of granting excessive privileges to individual users. Assigning an IAM policy directly to a user, as shown below with the users attribute, can increase the risk of credentials compromise or accidental permission escalation:
If left unaddressed, this practice can lead to difficulties in auditing permissions and increases the attack surface, as any compromise of a single user account could grant broad and unrestricted access to resources.
resource"aws_iam_user""user"{name="test-user"}resource"aws_iam_policy""policy"{name="test_policy"path="/"description="My test policy" # Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy= jsonencode({Version="2012-10-17"Statement=[{Action=["ec2:Describe*",]Effect="Allow"Resource="*"},]})}resource"aws_iam_user_policy_attachment""test-attach"{user=aws_iam_user.user.namepolicy_arn=aws_iam_policy.policy.arn}
1
2
rulesets:- Terraform / AWS # Rules to enforce / AWS.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.