Identity-based policies are attached to an IAM user, group, or role. These policies let you specify what that identity can do (its permissions).
Throughout this unit, we will create different policies and associate them with the role you’ve created in the previous unit.
If you haven’t created a role yet, here is a short recap.
Open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Roles, Create role.
On the Trusted entity type page, choose AWS service and the EC2 use case. Choose Next: Permissions.
On the Attach permissions policy page, search for AmazonS3FullAccess AWS managed policy.
The least privilege principle is a security best practice that involves giving users and systems only the minimum permissions necessary to perform their tasks or functions, and no more. This helps to reduce the risk of accidental or intentional damage or data loss, and limit the potential impact of security breaches or vulnerabilities.
Let’s narrow the above policy of your S3 bucket.
images/
STANDARD_IA
storage-class can be accessed.Using resource tags in an AWS policy can help you implement more granular access controls based on the tags assigned to the resources. By using tags in the policy, you can specify permissions for specific tags or tag values, which can make it easier to manage access and automate resource management based on tags.
Let’s see an example:
BucketPrefix
and some value according to your choice.images/
, try to allow access on a dynamic prefix according to the principal tag:"Resource": ["arn:aws:s3:::<your-bucket-name>/${aws:PrincipalTag/BucketPrefix}/*"]
In this section we are going to create a role which can start/stop EC2 instances belonging to the Development environment only.
Env
and value Dev
.Env=Dev
.Env
tag.Enforcing tagging policies for resources in AWS is considered a good practice. By enforcing a tagging policy, you can ensure that all resources are consistently labeled and organized, which makes it easier to identify, search, and manage resources and costs.
For example, you can use tags to label resources based on their project and environment. This can help you to quickly find and manage resources, monitor costs, and set up automation and policies based on tags.
Project
with allowed values of CloudMate
, PipelineX
, or SecureStack
(three imagined project names).Enter the interactive self-check page
Create the below policies following the Principle of the least privilege.
internal/
.STANDARD
and STANDARD_IA
storage classes only.us-east-1
region only.As you may know, Amazon S3 offers encryption in transit and encryption at rest. Encryption in transit refers to HTTPS and encryption at rest refers to client-side or server-side encryption.
Since Amazon S3 allows both HTTP and HTTPS requests, encryption in transit may be violated. We would like to create a resource-based policy that will be associated with an S3 bucket and will enforce HTTPS communication only.
Use this resource as a reference to define the policy and attach it to your bucket.
Attribute-based access control (ABAC) is an authorization strategy that defines permissions based on attributes. In AWS, these attributes are called tags. You can attach tags to almost any AWS resource (EC2 instance, S3 bucket), including IAM entities (users or roles).
ABAC policies can be designed to allow operations when the principal’s tag matches the resource tag. ABAC is helpful in environments that are growing rapidly and helps with situations where policy management becomes cumbersome.
Follow:
https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html