AWS Identity and Security
This page is about who may use AWS resources and how keys and secrets are kept. It covers IAM identities, credentials, and policies, then AWS KMS and AWS Secrets Manager. The practice run models two ideas on your own machine and needs no AWS account. It comes after AWS Networking and Delivery and before AWS Databases and Serverless.
41 min read41 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 33 sources33টি সোর্স · updated Nov 2026আপডেট: Nov 2026
How AWS decides a requestAWS কীভাবে একটা অনুরোধের সিদ্ধান্ত নেয়
Send Carlos's request through the policy checks and see why one explicit Deny beats any Allow.Carlos-এর অনুরোধ পলিসি যাচাইয়ের ভেতর দিয়ে পাঠান আর দেখুন কেন একটা স্পষ্ট Deny যেকোনো Allow-কে হারায়।
You’ll learnআপনি শিখবেন
- Every request starts as deniedপ্রতিটা অনুরোধ আটকানো অবস্থায় শুরু হয়✓
- AWS looks for an explicit Deny firstAWS আগে একটা explicit Deny খোঁজে
- Without any Allow, the default is denyকোনো Allow না থাকলে ডিফল্ট হলো আটকানো
- An explicit Deny beats any Allowএকটা explicit Deny যেকোনো Allow-কে হারায়
- The simulator tests without a real requestসিমুলেটর আসল অনুরোধ ছাড়াই পরীক্ষা করে
What it is
AWS IAM. AWS Identity and Access Management (IAM) is a web service that helps you securely control access to AWS resources Source 1সোর্স 1. You use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources Source 1সোর্স 1. There is no charge to use IAM Source 2সোর্স 2.
Identities. When you create an AWS account, you begin with one sign-in identity called the AWS account root user that has complete access to all AWS services and resources Source 1সোর্স 1. An IAM role is an IAM identity that you can create in your account that has specific permissions Source 4সোর্স 4. A role is intended to be assumable by anyone who needs it Source 4সোর্স 4. A role does not have standard long-term credentials such as a password or access keys associated with it Source 4সোর্স 4. When you assume a role, it provides you with temporary security credentials for your role session Source 4সোর্স 4.
Policies. A policy is an object in AWS that, when associated with an identity or resource, defines their permissions Source 9সোর্স 9. AWS evaluates these policies when an IAM principal (user or role) makes a request Source 9সোর্স 9. Permissions in the policies determine whether the request is allowed or denied Source 9সোর্স 9.
AWS KMS. AWS Key Management Service (AWS KMS) is an AWS managed service that makes it easy for you to create and control the keys used to encrypt and sign your data Source 17সোর্স 17. KMS keys are created, managed, used, and deleted entirely within AWS KMS Source 17সোর্স 17. They never leave the service unencrypted Source 17সোর্স 17.
AWS Secrets Manager. AWS Secrets Manager helps you manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles Source 24সোর্স 24. You replace hard-coded credentials with a runtime call to the Secrets Manager service to retrieve credentials dynamically when you need them Source 24সোর্স 24. For AWS credentials, AWS recommends AWS Identity and Access Management Source 24সোর্স 24. For encryption keys, it recommends AWS Key Management Service Source 24সোর্স 24.
সহজ English
AWS IAM. AWS Identity and Access Management (IAM) is a web service that helps you securely control access to AWS resources Source 1সোর্স 1. You use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources Source 1সোর্স 1. There is no charge to use IAM Source 2সোর্স 2.
Identities. When you create an AWS account, you begin with one sign-in identity called the AWS account root user that has complete access to all AWS services and resources Source 1সোর্স 1. An IAM role is an IAM identity that you can create in your account that has specific permissions Source 4সোর্স 4. A role is intended to be assumable by anyone who needs it Source 4সোর্স 4. A role does not have standard long-term credentials such as a password or access keys associated with it Source 4সোর্স 4. When you assume a role, it provides you with temporary security credentials for your role session Source 4সোর্স 4.
Policies. A policy is an object in AWS that, when associated with an identity or resource, defines their permissions Source 9সোর্স 9. AWS evaluates these policies when an IAM principal (user or role) makes a request Source 9সোর্স 9. Permissions in the policies determine whether the request is allowed or denied Source 9সোর্স 9.
AWS KMS. AWS Key Management Service (AWS KMS) is an AWS managed service that makes it easy for you to create and control the keys used to encrypt and sign your data Source 17সোর্স 17. KMS keys are created, managed, used, and deleted entirely within AWS KMS Source 17সোর্স 17. They never leave the service unencrypted Source 17সোর্স 17.
AWS Secrets Manager. AWS Secrets Manager helps you manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles Source 24সোর্স 24. You replace hard-coded credentials with a runtime call to the Secrets Manager service to retrieve credentials dynamically when you need them Source 24সোর্স 24. For AWS credentials, AWS recommends AWS Identity and Access Management Source 24সোর্স 24. For encryption keys, it recommends AWS Key Management Service Source 24সোর্স 24.
বাংলা ব্যাখ্যা
AWS IAM। AWS Identity and Access Management (IAM) একটা web service, যা AWS resource-এ প্রবেশাধিকার নিরাপদে নিয়ন্ত্রণ করতে আপনাকে সাহায্য করে Source 1সোর্স 1। কে authenticated (sign in করা) আর authorized (permission আছে) হয়ে resource ব্যবহার করতে পারবে, তা নিয়ন্ত্রণ করতে আপনি IAM ব্যবহার করেন Source 1সোর্স 1। IAM ব্যবহারের জন্য কোনো খরচ নেই Source 2সোর্স 2।
Identity। আপনি একটা AWS account বানালে একটা sign-in identity নিয়ে শুরু করেন, যার নাম AWS account root user, আর সব AWS service ও resource-এ তার পূর্ণ প্রবেশাধিকার আছে Source 1সোর্স 1। একটা IAM role হলো একটা IAM identity, যা আপনি নিজের account-এ বানাতে পারেন আর যার নির্দিষ্ট permission আছে Source 4সোর্স 4। একটা role এমনভাবে তৈরি যে যার দরকার সে-ই তা assume করতে পারে Source 4সোর্স 4। একটা role-এর সঙ্গে password বা access key-এর মতো স্বাভাবিক দীর্ঘমেয়াদি credential যুক্ত থাকে না Source 4সোর্স 4। আপনি একটা role assume করলে সেটা আপনাকে আপনার role session-এর জন্য অস্থায়ী security credential দেয় Source 4সোর্স 4।
Policy। একটা policy হলো AWS-এর একটা object, যা কোনো identity বা resource-এর সঙ্গে যুক্ত হলে তাদের permission ঠিক করে Source 9সোর্স 9। একজন IAM principal (user বা role) request করলে AWS এই policy-গুলো যাচাই করে Source 9সোর্স 9। policy-র permission ঠিক করে request অনুমতি পাবে না আটকানো হবে Source 9সোর্স 9।
AWS KMS। AWS Key Management Service (AWS KMS) হলো AWS-এর পরিচালিত একটা service, যা আপনার data encrypt ও sign করার keys বানানো আর নিয়ন্ত্রণ করা সহজ করে Source 17সোর্স 17। KMS key পুরোপুরি AWS KMS-এর ভেতরেই তৈরি, পরিচালিত, ব্যবহৃত ও মুছে ফেলা হয় Source 17সোর্স 17। সেগুলো কখনো encrypt না করা অবস্থায় service ছেড়ে বেরোয় না Source 17সোর্স 17।
AWS Secrets Manager। AWS Secrets Manager আপনাকে database credential, application credential, OAuth token, API key আর অন্যান্য secret-এর পুরো জীবনচক্র জুড়ে সেগুলো পরিচালনা, retrieve আর rotate করতে সাহায্য করে Source 24সোর্স 24। আপনি hard-coded credential-এর জায়গায় Secrets Manager service-এ একটা runtime call বসান, যাতে দরকারের সময় গতিশীলভাবে credential retrieve করা যায় Source 24সোর্স 24। AWS credential-এর জন্য AWS সুপারিশ করে AWS Identity and Access Management Source 24সোর্স 24। encryption key-এর জন্য সুপারিশ করে AWS Key Management Service Source 24সোর্স 24।
How it works
Sign-in, the root user, and MFA. Authentication is provided by matching the sign-in credentials to a principal trusted by the AWS account Source 1সোর্স 1. AWS strongly recommends that you don't use the root user for everyday tasks Source 1সোর্স 1. Use the root user only to perform the tasks that require root-level permissions Source 7সোর্স 7. You cannot attach identity-based policies to the root user Source 9সোর্স 9. MFA is enforced for root users by default Source 7সোর্স 7. Adding it requires customer action during the initial account creation or as prompted during sign-in Source 7সোর্স 7.
MFA requires users to provide unique authentication from an AWS supported MFA mechanism in addition to their sign-in credentials Source 8সোর্স 8. Your AWS account root user and IAM users can register up to eight MFA devices of any type Source 8সোর্স 8. You only need one MFA device to sign in to the AWS Management Console or create a session through the AWS CLI Source 8সোর্স 8. AWS recommends phishing-resistant MFA such as passkeys and security keys whenever possible Source 8সোর্স 8.
Access keys and temporary credentials. Access keys are long-term credentials for an IAM user or the AWS account root user Source 6সোর্স 6. You must use both the access key ID and secret access key together to authenticate your requests Source 6সোর্স 6. The secret access key can be retrieved only at the time you create it Source 6সোর্স 6. You can have a maximum of two access keys per user Source 6সোর্স 6. As a best practice, use temporary security credentials (such as IAM roles) instead of creating long-term credentials like access keys Source 6সোর্স 6.
Access keys or credential information stored in the shared AWS credentials file are stored in plaintext Source 6সোর্স 6. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Do NOT include files that contain access keys or credential information in your project area Source 6সোর্স 6.
You can use AWS STS to create and provide trusted users with temporary security credentials Source 5সোর্স 5. Temporary security credentials are short-term, as the name implies Source 5সোর্স 5. They can be configured to last for anywhere from a few minutes to several hours Source 5সোর্স 5. After the credentials expire, AWS no longer recognizes them Source 5সোর্স 5. They are not stored with the user but are generated dynamically when requested Source 5সোর্স 5.
Roles for workloads. When you're building on an AWS compute service, such as Amazon EC2 or Lambda, AWS delivers the temporary credentials of an IAM role to that compute resource Source 3সোর্স 3. Applications written using an AWS SDK will discover and use these temporary credentials Source 3সোর্স 3. When you launch an Amazon EC2 instance, you specify an IAM role to associate with the instance Source 16সোর্স 16. Applications that run on the instance can then use the role-supplied temporary credentials to sign API requests Source 16সোর্স 16. Only one role can be assigned to an Amazon EC2 instance at a time Source 16সোর্স 16. All applications on the instance share the same role and permissions Source 16সোর্স 16.
IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. AWS recommends that you do not include IAM changes in the critical, high-availability code paths of your application Source 1সোর্স 1. Be sure to verify that the changes have been propagated before production workflows depend on them Source 1সোর্স 1.
Policy types. Identity-based policies are JSON permissions policy documents that control what actions an identity can perform, on which resources, and under what conditions Source 9সোর্স 9. You attach managed and inline policies to IAM identities Source 9সোর্স 9. Managed policies are standalone identity-based policies that you can attach to multiple users, groups, and roles Source 9সোর্স 9. Inline policies are policies that you add directly to a single user, group, or role Source 9সোর্স 9. They are deleted when you delete the identity Source 9সোর্স 9.
Resource-based policies are JSON policy documents that you attach to a resource such as an Amazon S3 bucket Source 9সোর্স 9. They grant the specified principal permission to perform specific actions on that resource Source 9সোর্স 9. Resource-based policies are inline policies Source 9সোর্স 9. There are no managed resource-based policies Source 9সোর্স 9. Trust policies define which principal entities can assume the role Source 9সোর্স 9.
A permissions boundary sets the maximum permissions that an identity-based policy can grant to an IAM entity Source 9সোর্স 9. With a boundary, the entity can perform only the actions that both its identity-based policies and its boundary allow Source 9সোর্স 9.
Policy statements. Each statement includes information about a single permission Source 9সোর্স 9. If a policy includes multiple statements, AWS applies a logical OR across the statements Source 9সোর্স 9. If multiple policies apply to a request, AWS applies a logical OR across all of those policies Source 9সোর্স 9. These are the main elements:
Effect: useAlloworDenyto indicate whether the policy allows or denies access Source 9সোর্স 9.Action: a list of actions that the policy allows or denies Source 9সোর্স 9.Resource: an IAM permissions policy must specify a list of resources to which the actions apply Source 9সোর্স 9.Principal: in a resource-based policy, you must indicate the account, user, role, or AWS STS federated user principal Source 9সোর্স 9. In an identity-based policy, you cannot include this element Source 9সোর্স 9.Condition: it specifies the circumstances under which the policy grants permission Source 9সোর্স 9.
Policies are expressed in JSON Source 10সোর্স 10. Action names can include wildcards Source 10সোর্স 10. AWS recommends the latest 2012-10-17 version of the policy language Source 9সোর্স 9. If you try to define multiple permissions in a single statement, your policy might not grant the access that you expect Source 9সোর্স 9.
How AWS decides. By default, all requests are implicitly denied, except for the AWS account root user, which has full access Source 12সোর্স 12. A request must be explicitly allowed by a policy or set of policies to be allowed Source 12সোর্স 12. An explicit deny overrides an explicit allow Source 12সোর্স 12.
AWS looks in all applicable policies for a Deny statement that applies to the request Source 12সোর্স 12. This is called an explicit deny Source 12সোর্স 12. If it finds even one explicit deny that applies, the final decision is Deny Source 12সোর্স 12. If there is no explicit deny, the evaluation continues Source 12সোর্স 12.
Within one account, the identity-based and the resource-based policies both count. AWS evaluates all the permissions granted by the policies for at least one Allow Source 11সোর্স 11. If one of the two allows the request and the other doesn't, the request is still allowed Source 11সোর্স 11. For most resources, you only need an explicit Allow in one of them Source 12সোর্স 12. IAM role trust policies and KMS key policies are exceptions Source 12সোর্স 12. If a permissions boundary does not allow the requested action, the request is implicitly denied Source 12সোর্স 12.
A worked example. The page for a single account shows a user named Carlos and two policies Source 11সোর্স 11. The DenyS3Logs statement denies Carlos access to any S3 bucket with log in its name Source 11সোর্স 11. When Carlos saves a file in the logs bucket, AWS first checks for a Deny statement that applies to the request Source 11সোর্স 11. It finds one Source 11সোর্স 11. Carlos is denied access Source 11সোর্স 11. When he saves the file in his own bucket, AWS checks for a Deny statement and does not find one Source 11সোর্স 11. Both the identity-based policy and the resource-based policy allow the request Source 11সোর্স 11. Therefore, AWS allows the request Source 11সোর্স 11. If either of them explicitly denied the request, it would have been denied Source 11সোর্স 11.
Least privilege and checks. When you set permissions with IAM policies, grant only the permissions required to perform a task Source 3সোর্স 3. As your use case matures, you can work to reduce the permissions that you grant to work toward least privilege Source 3সোর্স 3. AWS managed policies might not grant least-privilege permissions for your specific use cases Source 3সোর্স 3. IAM provides last accessed information to help you identify what you no longer need Source 3সোর্স 3. You can specify conditions under which a policy statement is in effect Source 3সোর্স 3.
IAM Access Analyzer external access analyzers help identify resources that are shared with an external entity Source 15সোর্স 15. It generates IAM policies based on access activity in your AWS CloudTrail logs Source 15সোর্স 15. AWS automatically examines the policies that you create or edit in the console to ensure that they comply with the IAM policy grammar Source 14সোর্স 14. It also verifies that your ARNs are formatted properly and action names and condition keys are correct Source 14সোর্স 14.
The policy simulator. With the IAM policy simulator, you can test identity-based policies, IAM permissions boundaries, service control policies (SCPs), and resource-based policies that you provide Source 13সোর্স 13. You simulate how AWS would evaluate a request, without sending a real request to any AWS service Source 13সোর্স 13. Each simulation returns a binary authorization outcome for every action and resource you test Source 13সোর্স 13. In Custom mode, you test one or more policies that you write or paste in Source 13সোর্স 13. They are simulated on their own and are not saved to your account Source 13সোর্স 13. The simulator results can differ from your live AWS environment Source 13সোর্স 13. AWS recommends that you check your policies against your live environment after testing Source 13সোর্স 13.
KMS keys and data keys. When you encrypt data, you need to protect your encryption key Source 17সোর্স 17. If you encrypt your key, you need to protect its encryption key Source 17সোর্স 17. Eventually, you must protect the highest level encryption key, known as a root key Source 17সোর্স 17. Envelope encryption is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key Source 19সোর্স 19. Eventually, one key must remain in plaintext so you can decrypt the keys and your data Source 19সোর্স 19. This top-level plaintext key encryption key is known as the root key Source 19সোর্স 19. To use a KMS key, you must call AWS KMS Source 19সোর্স 19.
Data keys are symmetric keys you can use to encrypt data Source 20সোর্স 20. Data keys are returned to you for use outside of AWS KMS Source 20সোর্স 20. AWS KMS returns a plaintext data key for immediate use (optional) and an encrypted copy of the data key Source 20সোর্স 20. When you are ready to decrypt the data, you first ask AWS KMS to decrypt the encrypted data key Source 20সোর্স 20. AWS KMS does not store, manage, or track your data keys Source 20সোর্স 20. To create a data key, call the GenerateDataKey operation Source 20সোর্স 20. You can re-encrypt only the data keys instead of re-encrypting the raw data Source 19সোর্স 19.
KMS key types, rotation, and deletion. The KMS keys that you create are customer managed keys Source 18সোর্স 18. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. For a customer managed key, you can maintain its key policies, enable and disable it, rotate its cryptographic material, and schedule it for deletion Source 18সোর্স 18. You cannot change any properties of AWS managed keys, rotate them, change their key policies, or schedule them for deletion Source 18সোর্স 18. All AWS managed keys are automatically rotated every year Source 18সোর্স 18.
By default, when you enable automatic key rotation for a KMS key, AWS KMS generates new cryptographic material for it every year Source 21সোর্স 21. You can perform on-demand rotation to start a rotation at once Source 21সোর্স 21. When you use the rotated KMS key to decrypt ciphertext, AWS KMS uses the key material that was used to encrypt it Source 21সোর্স 21. You can safely use a rotated KMS key in applications without code changes Source 21সোর্স 21. The KMS key is the same logical resource, however often its key material changes Source 21সোর্স 21. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21. It does not rotate the data keys that the KMS key generated or re-encrypt any data Source 21সোর্স 21. Key rotation will not mitigate the effect of a compromised data key Source 21সোর্স 21.
Deleting an AWS KMS key is destructive and potentially dangerous Source 22সোর্স 22. It deletes the key material and all metadata associated with the KMS key and is irreversible Source 22সোর্স 22. After a KMS key is deleted, you can no longer decrypt the data that was encrypted under that KMS key Source 22সোর্স 22. AWS KMS requires a waiting period of 7 – 30 days Source 22সোর্স 22. The default waiting period is 30 days Source 22সোর্স 22. A KMS key pending deletion cannot be used in any cryptographic operations Source 22সোর্স 22. To recover the KMS key, you can cancel key deletion before the waiting period ends Source 22সোর্স 22. If you are not sure, consider disabling the KMS key instead of deleting it Source 22সোর্স 22. There is no charge for customer managed KMS keys that are scheduled for deletion Source 23সোর্স 23.
Secrets Manager: secrets, keys, and rotation. A secret can be a password, a set of credentials, an OAuth token, or other secret information that you store in an encrypted form Source 25সোর্স 25. You can store up to 65536 bytes in the secret Source 25সোর্স 25. To create a secret, you need the permissions granted by the SecretsManagerReadWrite managed policy Source 25সোর্স 25. Secrets Manager encrypts secrets at rest using encryption keys that you own and store in AWS KMS Source 27সোর্স 27. When you retrieve a secret, Secrets Manager decrypts it and transmits it securely over TLS to your local environment Source 27সোর্স 27. For most cases, choose aws/secretsmanager, the AWS managed key Source 25সোর্স 25. There is no cost for using this key Source 25সোর্স 25. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24.
With Secrets Manager, you can configure an automatic rotation schedule for your secrets Source 24সোর্স 24. Rotating credentials no longer requires updating your applications and deploying changes to application clients Source 24সোর্স 24. You can set up automatic rotation as often as every four hours Source 27সোর্স 27. Secrets Manager offers two strategies for rotation: Single user and Alternating users Source 27সোর্স 27. If you don't change your secrets for a long period of time, the secrets become more likely to be compromised Source 27সোর্স 27. When you turn on automatic rotation (except managed rotation), you are charged for the rotation function at the current Lambda rate Source 24সোর্স 24.
Secrets Manager: deleting and handling. Secrets Manager does not immediately delete secrets Source 26সোর্স 26. It immediately makes the secret inaccessible and schedules it for deletion after a recovery window of a minimum of seven days Source 26সোর্স 26. Until the recovery window ends, you can recover a secret you previously deleted Source 26সোর্স 26. There is no charge for secrets that you have marked for deletion Source 26সোর্স 26. You can't directly delete a version of a secret Source 26সোর্স 26. If you don't know whether an application still uses a secret, you can create an Amazon CloudWatch alarm for access attempts during the recovery window Source 26সোর্স 26. If you delete a secret without a recovery window, you can't recover it Source 26সোর্স 26.
When you use Secrets Manager, you pay only for what you use, with no minimum or setup fees Source 24সোর্স 24. Most command shells offer features that could compromise your secrets, such as logging and the ability to see the last entered command Source 27সোর্স 27. In IAM policy statements that control access to your secrets, use the principle of least privileged access Source 27সোর্স 27. To use your secrets most efficiently, cache them and update them only when required Source 27সোর্স 27.
সহজ English
Sign-in, the root user, and MFA. Authentication is provided by matching the sign-in credentials to a principal trusted by the AWS account Source 1সোর্স 1. AWS strongly recommends that you don't use the root user for everyday tasks Source 1সোর্স 1. Use the root user only to perform the tasks that require root-level permissions Source 7সোর্স 7. You cannot attach identity-based policies to the root user Source 9সোর্স 9. MFA is enforced for root users by default Source 7সোর্স 7. Adding it requires customer action during the initial account creation or as prompted during sign-in Source 7সোর্স 7.
MFA requires users to provide unique authentication from an AWS supported MFA mechanism in addition to their sign-in credentials Source 8সোর্স 8. Your AWS account root user and IAM users can register up to eight MFA devices of any type Source 8সোর্স 8. You only need one MFA device to sign in to the AWS Management Console or create a session through the AWS CLI Source 8সোর্স 8. AWS recommends phishing-resistant MFA such as passkeys and security keys whenever possible Source 8সোর্স 8.
Access keys and temporary credentials. Access keys are long-term credentials for an IAM user or the AWS account root user Source 6সোর্স 6. You must use both the access key ID and secret access key together to authenticate your requests Source 6সোর্স 6. The secret access key can be retrieved only at the time you create it Source 6সোর্স 6. You can have a maximum of two access keys per user Source 6সোর্স 6. As a best practice, use temporary security credentials (such as IAM roles) instead of creating long-term credentials like access keys Source 6সোর্স 6.
Access keys or credential information stored in the shared AWS credentials file are stored in plaintext Source 6সোর্স 6. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Do NOT include files that contain access keys or credential information in your project area Source 6সোর্স 6.
You can use AWS STS to create and provide trusted users with temporary security credentials Source 5সোর্স 5. Temporary security credentials are short-term, as the name implies Source 5সোর্স 5. They can be configured to last for anywhere from a few minutes to several hours Source 5সোর্স 5. After the credentials expire, AWS no longer recognizes them Source 5সোর্স 5. They are not stored with the user but are generated dynamically when requested Source 5সোর্স 5.
Roles for workloads. When you're building on an AWS compute service, such as Amazon EC2 or Lambda, AWS delivers the temporary credentials of an IAM role to that compute resource Source 3সোর্স 3. Applications written using an AWS SDK will discover and use these temporary credentials Source 3সোর্স 3. When you launch an Amazon EC2 instance, you specify an IAM role to associate with the instance Source 16সোর্স 16. Applications that run on the instance can then use the role-supplied temporary credentials to sign API requests Source 16সোর্স 16. Only one role can be assigned to an Amazon EC2 instance at a time Source 16সোর্স 16. All applications on the instance share the same role and permissions Source 16সোর্স 16.
IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. AWS recommends that you do not include IAM changes in the critical, high-availability code paths of your application Source 1সোর্স 1. Be sure to verify that the changes have been propagated before production workflows depend on them Source 1সোর্স 1.
Policy types. Identity-based policies are JSON permissions policy documents that control what actions an identity can perform, on which resources, and under what conditions Source 9সোর্স 9. You attach managed and inline policies to IAM identities Source 9সোর্স 9. Managed policies are standalone identity-based policies that you can attach to multiple users, groups, and roles Source 9সোর্স 9. Inline policies are policies that you add directly to a single user, group, or role Source 9সোর্স 9. They are deleted when you delete the identity Source 9সোর্স 9.
Resource-based policies are JSON policy documents that you attach to a resource such as an Amazon S3 bucket Source 9সোর্স 9. They grant the specified principal permission to perform specific actions on that resource Source 9সোর্স 9. Resource-based policies are inline policies Source 9সোর্স 9. There are no managed resource-based policies Source 9সোর্স 9. Trust policies define which principal entities can assume the role Source 9সোর্স 9.
A permissions boundary sets the maximum permissions that an identity-based policy can grant to an IAM entity Source 9সোর্স 9. With a boundary, the entity can perform only the actions that both its identity-based policies and its boundary allow Source 9সোর্স 9.
Policy statements. Each statement includes information about a single permission Source 9সোর্স 9. If a policy includes multiple statements, AWS applies a logical OR across the statements Source 9সোর্স 9. If multiple policies apply to a request, AWS applies a logical OR across all of those policies Source 9সোর্স 9. These are the main elements:
Effect: useAlloworDenyto indicate whether the policy allows or denies access Source 9সোর্স 9.Action: a list of actions that the policy allows or denies Source 9সোর্স 9.Resource: an IAM permissions policy must specify a list of resources to which the actions apply Source 9সোর্স 9.Principal: in a resource-based policy, you must indicate the account, user, role, or AWS STS federated user principal Source 9সোর্স 9. In an identity-based policy, you cannot include this element Source 9সোর্স 9.Condition: it specifies the circumstances under which the policy grants permission Source 9সোর্স 9.
Policies are expressed in JSON Source 10সোর্স 10. Action names can include wildcards Source 10সোর্স 10. AWS recommends the latest 2012-10-17 version of the policy language Source 9সোর্স 9. If you try to define multiple permissions in a single statement, your policy might not grant the access that you expect Source 9সোর্স 9.
How AWS decides. By default, all requests are implicitly denied, except for the AWS account root user, which has full access Source 12সোর্স 12. A request must be explicitly allowed by a policy or set of policies to be allowed Source 12সোর্স 12. An explicit deny overrides an explicit allow Source 12সোর্স 12.
AWS looks in all applicable policies for a Deny statement that applies to the request Source 12সোর্স 12. This is called an explicit deny Source 12সোর্স 12. If it finds even one explicit deny that applies, the final decision is Deny Source 12সোর্স 12. If there is no explicit deny, the evaluation continues Source 12সোর্স 12.
Within one account, the identity-based and the resource-based policies both count. AWS evaluates all the permissions granted by the policies for at least one Allow Source 11সোর্স 11. If one of the two allows the request and the other doesn't, the request is still allowed Source 11সোর্স 11. For most resources, you only need an explicit Allow in one of them Source 12সোর্স 12. IAM role trust policies and KMS key policies are exceptions Source 12সোর্স 12. If a permissions boundary does not allow the requested action, the request is implicitly denied Source 12সোর্স 12.
A worked example. The page for a single account shows a user named Carlos and two policies Source 11সোর্স 11. The DenyS3Logs statement denies Carlos access to any S3 bucket with log in its name Source 11সোর্স 11. When Carlos saves a file in the logs bucket, AWS first checks for a Deny statement that applies to the request Source 11সোর্স 11. It finds one Source 11সোর্স 11. Carlos is denied access Source 11সোর্স 11. When he saves the file in his own bucket, AWS checks for a Deny statement and does not find one Source 11সোর্স 11. Both the identity-based policy and the resource-based policy allow the request Source 11সোর্স 11. Therefore, AWS allows the request Source 11সোর্স 11. If either of them explicitly denied the request, it would have been denied Source 11সোর্স 11.
Least privilege and checks. When you set permissions with IAM policies, grant only the permissions required to perform a task Source 3সোর্স 3. As your use case matures, you can work to reduce the permissions that you grant to work toward least privilege Source 3সোর্স 3. AWS managed policies might not grant least-privilege permissions for your specific use cases Source 3সোর্স 3. IAM provides last accessed information to help you identify what you no longer need Source 3সোর্স 3. You can specify conditions under which a policy statement is in effect Source 3সোর্স 3.
IAM Access Analyzer external access analyzers help identify resources that are shared with an external entity Source 15সোর্স 15. It generates IAM policies based on access activity in your AWS CloudTrail logs Source 15সোর্স 15. AWS automatically examines the policies that you create or edit in the console to ensure that they comply with the IAM policy grammar Source 14সোর্স 14. It also verifies that your ARNs are formatted properly and action names and condition keys are correct Source 14সোর্স 14.
The policy simulator. With the IAM policy simulator, you can test identity-based policies, IAM permissions boundaries, service control policies (SCPs), and resource-based policies that you provide Source 13সোর্স 13. You simulate how AWS would evaluate a request, without sending a real request to any AWS service Source 13সোর্স 13. Each simulation returns a binary authorization outcome for every action and resource you test Source 13সোর্স 13. In Custom mode, you test one or more policies that you write or paste in Source 13সোর্স 13. They are simulated on their own and are not saved to your account Source 13সোর্স 13. The simulator results can differ from your live AWS environment Source 13সোর্স 13. AWS recommends that you check your policies against your live environment after testing Source 13সোর্স 13.
KMS keys and data keys. When you encrypt data, you need to protect your encryption key Source 17সোর্স 17. If you encrypt your key, you need to protect its encryption key Source 17সোর্স 17. Eventually, you must protect the highest level encryption key, known as a root key Source 17সোর্স 17. Envelope encryption is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key Source 19সোর্স 19. Eventually, one key must remain in plaintext so you can decrypt the keys and your data Source 19সোর্স 19. This top-level plaintext key encryption key is known as the root key Source 19সোর্স 19. To use a KMS key, you must call AWS KMS Source 19সোর্স 19.
Data keys are symmetric keys you can use to encrypt data Source 20সোর্স 20. Data keys are returned to you for use outside of AWS KMS Source 20সোর্স 20. AWS KMS returns a plaintext data key for immediate use (optional) and an encrypted copy of the data key Source 20সোর্স 20. When you are ready to decrypt the data, you first ask AWS KMS to decrypt the encrypted data key Source 20সোর্স 20. AWS KMS does not store, manage, or track your data keys Source 20সোর্স 20. To create a data key, call the GenerateDataKey operation Source 20সোর্স 20. You can re-encrypt only the data keys instead of re-encrypting the raw data Source 19সোর্স 19.
KMS key types, rotation, and deletion. The KMS keys that you create are customer managed keys Source 18সোর্স 18. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. For a customer managed key, you can maintain its key policies, enable and disable it, rotate its cryptographic material, and schedule it for deletion Source 18সোর্স 18. You cannot change any properties of AWS managed keys, rotate them, change their key policies, or schedule them for deletion Source 18সোর্স 18. All AWS managed keys are automatically rotated every year Source 18সোর্স 18.
By default, when you enable automatic key rotation for a KMS key, AWS KMS generates new cryptographic material for it every year Source 21সোর্স 21. You can perform on-demand rotation to start a rotation at once Source 21সোর্স 21. When you use the rotated KMS key to decrypt ciphertext, AWS KMS uses the key material that was used to encrypt it Source 21সোর্স 21. You can safely use a rotated KMS key in applications without code changes Source 21সোর্স 21. The KMS key is the same logical resource, however often its key material changes Source 21সোর্স 21. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21. It does not rotate the data keys that the KMS key generated or re-encrypt any data Source 21সোর্স 21. Key rotation will not mitigate the effect of a compromised data key Source 21সোর্স 21.
Deleting an AWS KMS key is destructive and potentially dangerous Source 22সোর্স 22. It deletes the key material and all metadata associated with the KMS key and is irreversible Source 22সোর্স 22. After a KMS key is deleted, you can no longer decrypt the data that was encrypted under that KMS key Source 22সোর্স 22. AWS KMS requires a waiting period of 7 – 30 days Source 22সোর্স 22. The default waiting period is 30 days Source 22সোর্স 22. A KMS key pending deletion cannot be used in any cryptographic operations Source 22সোর্স 22. To recover the KMS key, you can cancel key deletion before the waiting period ends Source 22সোর্স 22. If you are not sure, consider disabling the KMS key instead of deleting it Source 22সোর্স 22. There is no charge for customer managed KMS keys that are scheduled for deletion Source 23সোর্স 23.
Secrets Manager: secrets, keys, and rotation. A secret can be a password, a set of credentials, an OAuth token, or other secret information that you store in an encrypted form Source 25সোর্স 25. You can store up to 65536 bytes in the secret Source 25সোর্স 25. To create a secret, you need the permissions granted by the SecretsManagerReadWrite managed policy Source 25সোর্স 25. Secrets Manager encrypts secrets at rest using encryption keys that you own and store in AWS KMS Source 27সোর্স 27. When you retrieve a secret, Secrets Manager decrypts it and transmits it securely over TLS to your local environment Source 27সোর্স 27. For most cases, choose aws/secretsmanager, the AWS managed key Source 25সোর্স 25. There is no cost for using this key Source 25সোর্স 25. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24.
With Secrets Manager, you can configure an automatic rotation schedule for your secrets Source 24সোর্স 24. Rotating credentials no longer requires updating your applications and deploying changes to application clients Source 24সোর্স 24. You can set up automatic rotation as often as every four hours Source 27সোর্স 27. Secrets Manager offers two strategies for rotation: Single user and Alternating users Source 27সোর্স 27. If you don't change your secrets for a long period of time, the secrets become more likely to be compromised Source 27সোর্স 27. When you turn on automatic rotation (except managed rotation), you are charged for the rotation function at the current Lambda rate Source 24সোর্স 24.
Secrets Manager: deleting and handling. Secrets Manager does not immediately delete secrets Source 26সোর্স 26. It immediately makes the secret inaccessible and schedules it for deletion after a recovery window of a minimum of seven days Source 26সোর্স 26. Until the recovery window ends, you can recover a secret you previously deleted Source 26সোর্স 26. There is no charge for secrets that you have marked for deletion Source 26সোর্স 26. You can't directly delete a version of a secret Source 26সোর্স 26. If you don't know whether an application still uses a secret, you can create an Amazon CloudWatch alarm for access attempts during the recovery window Source 26সোর্স 26. If you delete a secret without a recovery window, you can't recover it Source 26সোর্স 26.
When you use Secrets Manager, you pay only for what you use, with no minimum or setup fees Source 24সোর্স 24. Most command shells offer features that could compromise your secrets, such as logging and the ability to see the last entered command Source 27সোর্স 27. In IAM policy statements that control access to your secrets, use the principle of least privileged access Source 27সোর্স 27. To use your secrets most efficiently, cache them and update them only when required Source 27সোর্স 27.
বাংলা ব্যাখ্যা
Sign-in, root user আর MFA। Authentication হয় sign-in credential-কে AWS account-এর বিশ্বস্ত একজন principal-এর সঙ্গে মিলিয়ে Source 1সোর্স 1। AWS জোর দিয়ে সুপারিশ করে, আপনি যেন প্রতিদিনের কাজে root user ব্যবহার না করেন Source 1সোর্স 1। root user ব্যবহার করুন শুধু সেই কাজে, যার জন্য root-level permission লাগে Source 7সোর্স 7। আপনি root user-এ identity-based policy attach করতে পারেন না Source 9সোর্স 9। root user-এর জন্য MFA by default বাধ্যতামূলক Source 7সোর্স 7। সেটা যোগ করতে account তৈরির সময় বা sign-in-এর সময় চাওয়া হলে গ্রাহকের পদক্ষেপ লাগে Source 7সোর্স 7।
MFA ব্যবহারকারীদের sign-in credential-এর পাশাপাশি AWS-সমর্থিত একটা MFA ব্যবস্থা থেকে অনন্য authentication দিতে বলে Source 8সোর্স 8। আপনার AWS account root user আর IAM user যেকোনো ধরনের আটটা পর্যন্ত MFA device register করতে পারে Source 8সোর্স 8। AWS Management Console-এ sign in করতে বা AWS CLI দিয়ে session বানাতে আপনার মাত্র একটা MFA device লাগে Source 8সোর্স 8। AWS যতটা সম্ভব passkey আর security key-এর মতো phishing-resistant MFA ব্যবহারের সুপারিশ করে Source 8সোর্স 8।
Access key আর অস্থায়ী credential। Access key হলো একজন IAM user বা AWS account root user-এর দীর্ঘমেয়াদি credential Source 6সোর্স 6। আপনার request authenticate করতে access key ID আর secret access key দুটোই একসঙ্গে ব্যবহার করতে হয় Source 6সোর্স 6। secret access key শুধু তৈরির সময়ই retrieve করা যায় Source 6সোর্স 6। একজন user-এর সর্বোচ্চ দুটো access key থাকতে পারে Source 6সোর্স 6। সেরা চর্চা হিসেবে access key-এর মতো দীর্ঘমেয়াদি credential বানানোর বদলে অস্থায়ী security credential (যেমন IAM role) ব্যবহার করুন Source 6সোর্স 6।
shared AWS credentials file-এ রাখা access key বা credential তথ্য plaintext-এ থাকে Source 6সোর্স 6। আপনার application file-এ access key বা credential তথ্য রাখবেন না Source 6সোর্স 6। access key বা credential তথ্য আছে এমন file আপনার project এলাকায় রাখবেন না Source 6সোর্স 6।
আপনি AWS STS দিয়ে বিশ্বস্ত user-দের অস্থায়ী security credential বানিয়ে দিতে পারেন Source 5সোর্স 5। অস্থায়ী security credential নামের মতোই স্বল্পমেয়াদি Source 5সোর্স 5। সেগুলো কয়েক মিনিট থেকে কয়েক ঘণ্টা পর্যন্ত টিকে থাকার মতো করে configure করা যায় Source 5সোর্স 5। credential-এর মেয়াদ শেষ হলে AWS আর সেগুলো চেনে না Source 5সোর্স 5। সেগুলো user-এর সঙ্গে জমা থাকে না, চাওয়ামাত্র গতিশীলভাবে তৈরি হয় Source 5সোর্স 5।
Workload-এর জন্য role। আপনি যখন Amazon EC2 বা Lambda-র মতো কোনো AWS compute service-এর ওপর কিছু বানান, তখন AWS একটা IAM role-এর অস্থায়ী credential সেই compute resource-এ পৌঁছে দেয় Source 3সোর্স 3। AWS SDK দিয়ে লেখা application এই অস্থায়ী credential খুঁজে নিয়ে ব্যবহার করে Source 3সোর্স 3। আপনি একটা Amazon EC2 instance চালু করার সময় তার সঙ্গে যুক্ত করার জন্য একটা IAM role ঠিক করেন Source 16সোর্স 16। instance-এ চলা application তখন role-এর দেওয়া অস্থায়ী credential দিয়ে API request sign করতে পারে Source 16সোর্স 16। একটা Amazon EC2 instance-এ একসময়ে শুধু একটা role দেওয়া যায় Source 16সোর্স 16। instance-এর সব application একই role আর permission ভাগ করে ব্যবহার করে Source 16সোর্স 16।
IAM, অন্য অনেক AWS service-এর মতোই, eventually consistent Source 1সোর্স 1। AWS সুপারিশ করে, আপনার application-এর জরুরি, high-availability code path-এ IAM-এর এমন পরিবর্তন রাখবেন না Source 1সোর্স 1। production workflow এই পরিবর্তনের ওপর নির্ভর করার আগে নিশ্চিত হয়ে নিন যে পরিবর্তনগুলো ছড়িয়ে গেছে Source 1সোর্স 1।
Policy-র ধরন। Identity-based policy হলো JSON permissions policy document, যা ঠিক করে একটা identity কোন action করতে পারবে, কোন resource-এ আর কোন শর্তে Source 9সোর্স 9। আপনি managed আর inline policy IAM identity-তে attach করেন Source 9সোর্স 9। Managed policy হলো আলাদা (standalone) identity-based policy, যা আপনি একাধিক user, group আর role-এ attach করতে পারেন Source 9সোর্স 9। Inline policy হলো এমন policy, যা আপনি সরাসরি একটা user, group বা role-এ যোগ করেন Source 9সোর্স 9। identity মুছলে সেগুলোও মুছে যায় Source 9সোর্স 9।
Resource-based policy হলো JSON policy document, যা আপনি Amazon S3 bucket-এর মতো একটা resource-এ attach করেন Source 9সোর্স 9। সেগুলো নির্দিষ্ট করা principal-কে ওই resource-এ নির্দিষ্ট action করার permission দেয় Source 9সোর্স 9। Resource-based policy হলো inline policy Source 9সোর্স 9। managed resource-based policy নেই Source 9সোর্স 9। Trust policy ঠিক করে কোন principal entity role-টা assume করতে পারবে Source 9সোর্স 9।
Permissions boundary একটা IAM entity-কে identity-based policy সর্বোচ্চ কোন permission দিতে পারে, তা ঠিক করে Source 9সোর্স 9। boundary থাকলে entity শুধু সেই action করতে পারে, যা তার identity-based policy আর boundary দুটোই অনুমতি দেয় Source 9সোর্স 9।
Policy statement। প্রতিটা statement একটা মাত্র permission-এর তথ্য রাখে Source 9সোর্স 9। একটা policy-তে একাধিক statement থাকলে AWS evaluate করার সময় statement-গুলোর ওপর logical OR প্রয়োগ করে Source 9সোর্স 9। একটা request-এ একাধিক policy প্রযোজ্য হলে AWS সেই সব policy-র ওপর logical OR প্রয়োগ করে Source 9সোর্স 9। প্রধান element-গুলো:
Effect: policy অনুমতি দেয় না আটকায়, তা বোঝাতেAllowবাDenyব্যবহার করুন Source 9সোর্স 9।Action: policy যে action-গুলোর অনুমতি দেয় বা আটকায়, তার তালিকা Source 9সোর্স 9।Resource: একটা IAM permissions policy-তে এমন resource-এর তালিকা দিতে হয়, যেগুলোর ওপর action প্রযোজ্য Source 9সোর্স 9।Principal: একটা resource-based policy-তে account, user, role বা AWS STS federated user principal ঠিক করে দিতে হয় Source 9সোর্স 9। identity-based policy-তে এই element রাখা যায় না Source 9সোর্স 9।Condition: এটা ঠিক করে policy কোন পরিস্থিতিতে permission দেয় Source 9সোর্স 9।
Policy JSON-এ লেখা হয় Source 10সোর্স 10। Action-এর নামে wildcard থাকতে পারে Source 10সোর্স 10। AWS policy language-এর সর্বশেষ 2012-10-17 version ব্যবহারের সুপারিশ করে Source 9সোর্স 9। একটা statement-এ একাধিক permission ঠিক করতে গেলে আপনার policy আপনার প্রত্যাশিত access নাও দিতে পারে Source 9সোর্স 9।
AWS কীভাবে সিদ্ধান্ত নেয়। By default সব request implicitly denied হয়, শুধু AWS account root user বাদে, যার পূর্ণ প্রবেশাধিকার আছে Source 12সোর্স 12। একটা request অনুমতি পেতে হলে কোনো policy বা policy-র সেট তাকে স্পষ্টভাবে অনুমতি দিতে হয় Source 12সোর্স 12। explicit deny explicit allow-কে বাতিল করে দেয় Source 12সোর্স 12।
AWS সব প্রযোজ্য policy-তে খোঁজে, এমন একটা Deny statement আছে কি না যা request-টার ওপর প্রযোজ্য Source 12সোর্স 12। একে বলা হয় explicit deny Source 12সোর্স 12। প্রযোজ্য একটা explicit deny পেলেও চূড়ান্ত সিদ্ধান্ত হয় Deny Source 12সোর্স 12। কোনো explicit deny না থাকলে evaluation এগিয়ে চলে Source 12সোর্স 12।
একটা account-এর ভেতরে identity-based আর resource-based policy দুটোই গণনায় আসে। AWS policy-গুলোর দেওয়া সব permission দেখে, অন্তত একটা Allow-এর জন্য Source 11সোর্স 11। দুটোর একটা request-টা অনুমতি দিলে আর অন্যটা না দিলেও request অনুমতি পায় Source 11সোর্স 11। বেশির ভাগ resource-এর জন্য এর যেকোনো একটাতে একটা explicit Allow-ই যথেষ্ট Source 12সোর্স 12। IAM role trust policy আর KMS key policy এর ব্যতিক্রম Source 12সোর্স 12। একটা permissions boundary চাওয়া action-এর অনুমতি না দিলে request implicitly denied হয় Source 12সোর্স 12।
একটা কাজের উদাহরণ। একটা account-এর ভেতরের request-এর page-এ Carlos নামের একজন user আর দুটো policy দেখানো আছে Source 11সোর্স 11। DenyS3Logs statement Carlos-কে এমন যেকোনো S3 bucket-এ প্রবেশ করতে বাধা দেয়, যার নামে log আছে Source 11সোর্স 11। Carlos logs bucket-এ একটা file save করলে AWS আগে এমন একটা Deny statement খোঁজে, যা request-টার ওপর প্রযোজ্য Source 11সোর্স 11। সে একটা পায় Source 11সোর্স 11। Carlos-এর প্রবেশ আটকানো হয় Source 11সোর্স 11। সে নিজের bucket-এ file save করলে AWS একটা Deny statement খোঁজে আর পায় না Source 11সোর্স 11। identity-based policy আর resource-based policy দুটোই request-টা অনুমতি দেয় Source 11সোর্স 11। তাই AWS request-টা অনুমতি দেয় Source 11সোর্স 11। এর কোনোটা request-টা explicit deny করলে সেটা আটকানো হতো Source 11সোর্স 11।
Least privilege আর যাচাই। IAM policy দিয়ে permission ঠিক করার সময় কাজটা করার জন্য যতটুকু permission দরকার, শুধু ততটুকুই দিন Source 3সোর্স 3। আপনার ব্যবহারের ক্ষেত্র পরিণত হলে আপনি দেওয়া permission কমিয়ে least privilege-এর দিকে এগোতে পারেন Source 3সোর্স 3। AWS managed policy আপনার নির্দিষ্ট ব্যবহারের জন্য least-privilege permission নাও দিতে পারে Source 3সোর্স 3। IAM last accessed তথ্য দেয়, যাতে আপনি কী আর দরকার নেই তা শনাক্ত করতে পারেন Source 3সোর্স 3। আপনি এমন শর্ত ঠিক করতে পারেন, যে শর্তে একটা policy statement কার্যকর থাকে Source 3সোর্স 3।
IAM Access Analyzer-এর external access analyzer এমন resource শনাক্ত করতে সাহায্য করে, যা কোনো বাইরের সত্তার সঙ্গে ভাগ করা Source 15সোর্স 15। এটা আপনার AWS CloudTrail log-এর access activity থেকে IAM policy তৈরি করে Source 15সোর্স 15। আপনি console-এ যে policy বানান বা সম্পাদনা করেন, AWS স্বয়ংক্রিয়ভাবে সেগুলো পরীক্ষা করে দেখে, IAM policy grammar মানা হচ্ছে কি না Source 14সোর্স 14। এটা আরও যাচাই করে যে আপনার ARN ঠিকভাবে লেখা আর action-এর নাম ও condition key সঠিক Source 14সোর্স 14।
Policy simulator। IAM policy simulator দিয়ে আপনি আপনার দেওয়া identity-based policy, IAM permissions boundary, service control policy (SCP) আর resource-based policy test করতে পারেন Source 13সোর্স 13। কোনো AWS service-এ আসল request না পাঠিয়ে আপনি দেখে নেন AWS একটা request কীভাবে evaluate করত Source 13সোর্স 13। প্রতিটা simulation আপনার test করা প্রতিটা action ও resource-এর জন্য একটা দুই-মানের authorization ফল দেয় Source 13সোর্স 13। Custom mode-এ আপনি আপনার লেখা বা paste করা এক বা একাধিক policy test করেন Source 13সোর্স 13। সেগুলো আলাদাভাবে simulate হয়, আপনার account-এ save হয় না Source 13সোর্স 13। simulator-এর ফল আপনার live AWS environment-এর থেকে আলাদা হতে পারে Source 13সোর্স 13। AWS সুপারিশ করে, test করার পর আপনার policy আপনার live environment-এ যাচাই করুন Source 13সোর্স 13।
KMS key আর data key। আপনি data encrypt করলে আপনার encryption key-কে সুরক্ষিত রাখতে হয় Source 17সোর্স 17। আপনি আপনার key encrypt করলে তার encryption key-কে সুরক্ষিত রাখতে হয় Source 17সোর্স 17। শেষমেশ আপনাকে সবচেয়ে ওপরের স্তরের encryption key-কে সুরক্ষিত রাখতে হয়, যার নাম root key Source 17সোর্স 17। Envelope encryption হলো plaintext data-কে একটা data key দিয়ে encrypt করা, তারপর সেই data key-কে অন্য একটা key দিয়ে encrypt করার চর্চা Source 19সোর্স 19। শেষমেশ একটা key plaintext-এ থেকে যেতে হয়, যাতে আপনি key আর আপনার data decrypt করতে পারেন Source 19সোর্স 19। এই সবচেয়ে ওপরের plaintext key encryption key-এর নাম root key Source 19সোর্স 19। একটা KMS key ব্যবহার করতে আপনাকে AWS KMS-কে call করতে হয় Source 19সোর্স 19।
Data key হলো symmetric key, যা দিয়ে আপনি data encrypt করতে পারেন Source 20সোর্স 20। Data key আপনাকে ফেরত দেওয়া হয়, AWS KMS-এর বাইরে ব্যবহারের জন্য Source 20সোর্স 20। AWS KMS একটা plaintext data key (সঙ্গে সঙ্গে ব্যবহারের জন্য, ঐচ্ছিক) আর data key-র একটা encrypted copy ফেরত দেয় Source 20সোর্স 20। আপনি data decrypt করতে তৈরি হলে আগে AWS KMS-কে encrypted data key decrypt করতে বলেন Source 20সোর্স 20। AWS KMS আপনার data key জমা রাখে না, পরিচালনা করে না, আর হিসাবও রাখে না Source 20সোর্স 20। একটা data key বানাতে GenerateDataKey operation call করুন Source 20সোর্স 20। কাঁচা data বারবার re-encrypt করার বদলে আপনি শুধু data key-গুলো re-encrypt করতে পারেন Source 19সোর্স 19।
KMS key-র ধরন, rotation আর মুছে ফেলা। আপনার বানানো KMS key-গুলো customer managed key Source 18সোর্স 18। আপনার account-এ একটা customer managed key রাখার জন্য মাসিক খরচ আছে Source 18সোর্স 18। একটা customer managed key-র জন্য আপনি তার key policy রাখতে ও বদলাতে, সেটা enable ও disable করতে, তার cryptographic material rotate করতে আর সেটা মুছে ফেলার জন্য schedule করতে পারেন Source 18সোর্স 18। AWS managed key-র কোনো property আপনি বদলাতে, সেগুলো rotate করতে, তাদের key policy বদলাতে বা মুছে ফেলার জন্য schedule করতে পারেন না Source 18সোর্স 18। সব AWS managed key প্রতি বছর স্বয়ংক্রিয়ভাবে rotate হয় Source 18সোর্স 18।
By default, আপনি একটা KMS key-র জন্য automatic key rotation চালু করলে AWS KMS প্রতি বছর সেটার জন্য নতুন cryptographic material তৈরি করে Source 21সোর্স 21। এক্ষুনি rotation শুরু করতে আপনি on-demand rotation করতে পারেন Source 21সোর্স 21। আপনি rotate হওয়া KMS key দিয়ে ciphertext decrypt করলে AWS KMS সেই key material ব্যবহার করে, যা দিয়ে ciphertext encrypt হয়েছিল Source 21সোর্স 21। আপনি rotate হওয়া KMS key code বদলানো ছাড়াই application-এ নিরাপদে ব্যবহার করতে পারেন Source 21সোর্স 21। KMS key একই logical resource থাকে, তার key material যতবারই বদলাক Source 21সোর্স 21। Key rotation KMS key যে data রক্ষা করে, তার ওপর কোনো প্রভাব ফেলে না Source 21সোর্স 21। এটা KMS key-র বানানো data key rotate করে না, আর কোনো data re-encrypt করে না Source 21সোর্স 21। Key rotation একটা ফাঁস হওয়া data key-র প্রভাব কমায় না Source 21সোর্স 21।
একটা AWS KMS key মুছে ফেলা ধ্বংসাত্মক আর সম্ভাব্য বিপজ্জনক Source 22সোর্স 22। এটা key material আর KMS key-র সঙ্গে যুক্ত সব metadata মুছে দেয়, আর এটা ফেরানো যায় না Source 22সোর্স 22। একটা KMS key মুছে গেলে সেই KMS key-র অধীনে encrypt হওয়া data আপনি আর decrypt করতে পারেন না Source 22সোর্স 22। AWS KMS ৭ – ৩০ দিনের একটা অপেক্ষার সময় দাবি করে Source 22সোর্স 22। default অপেক্ষার সময় ৩০ দিন Source 22সোর্স 22। মুছে ফেলার অপেক্ষায় থাকা KMS key কোনো cryptographic operation-এ ব্যবহার করা যায় না Source 22সোর্স 22। KMS key ফিরিয়ে আনতে আপনি অপেক্ষার সময় শেষ হওয়ার আগে মুছে ফেলা বাতিল করতে পারেন Source 22সোর্স 22। আপনি নিশ্চিত না হলে KMS key মুছে ফেলার বদলে disable করার কথা ভাবুন Source 22সোর্স 22। মুছে ফেলার জন্য schedule করা customer managed KMS key-র জন্য কোনো খরচ নেই Source 23সোর্স 23।
Secrets Manager: secret, key আর rotation। একটা secret হতে পারে একটা password, একটা credential-এর সেট, একটা OAuth token বা অন্য গোপন তথ্য, যা আপনি encrypt করা রূপে রাখেন Source 25সোর্স 25। আপনি একটা secret-এ ৬৫৫৩৬ byte পর্যন্ত রাখতে পারেন Source 25সোর্স 25। একটা secret বানাতে আপনার SecretsManagerReadWrite managed policy-র দেওয়া permission লাগে Source 25সোর্স 25। Secrets Manager secret-গুলো জমা অবস্থায় encrypt করে, এমন encryption key দিয়ে, যা আপনার মালিকানায় আর AWS KMS-এ রাখা Source 27সোর্স 27। আপনি একটা secret retrieve করলে Secrets Manager সেটা decrypt করে TLS দিয়ে নিরাপদে আপনার local environment-এ পাঠায় Source 27সোর্স 27। বেশির ভাগ ক্ষেত্রে AWS managed key aws/secretsmanager বেছে নিন Source 25সোর্স 25। এই key ব্যবহারের জন্য কোনো খরচ নেই Source 25সোর্স 25। আপনি আপনার secret encrypt করতে নিজের KMS key বানালে AWS আপনার কাছ থেকে বর্তমান AWS KMS হারে খরচ নেয় Source 24সোর্স 24।
Secrets Manager দিয়ে আপনি আপনার secret-এর জন্য একটা স্বয়ংক্রিয় rotation-এর সূচি ঠিক করতে পারেন Source 24সোর্স 24। credential rotate করতে আর আপনার application হালনাগাদ করা এবং application client-এ পরিবর্তন deploy করা লাগে না Source 24সোর্স 24। আপনি প্রতি চার ঘণ্টায়ও স্বয়ংক্রিয় rotation চালু করতে পারেন Source 27সোর্স 27। Secrets Manager rotation-এর দুটো কৌশল দেয়: Single user আর Alternating users Source 27সোর্স 27। আপনি অনেক দিন secret না বদলালে সেগুলো ফাঁস হওয়ার সম্ভাবনা বাড়ে Source 27সোর্স 27। আপনি স্বয়ংক্রিয় rotation চালু করলে (managed rotation বাদে) rotation function-এর জন্য বর্তমান Lambda হারে খরচ হয় Source 24সোর্স 24।
Secrets Manager: মুছে ফেলা আর সামলানো। Secrets Manager secret সঙ্গে সঙ্গে মুছে ফেলে না Source 26সোর্স 26। সে secret-টাকে সঙ্গে সঙ্গে অপ্রবেশযোগ্য করে দেয় আর কমপক্ষে সাত দিনের একটা recovery window-এর পর মুছে ফেলার জন্য schedule করে Source 26সোর্স 26। recovery window শেষ না হওয়া পর্যন্ত আপনি আগে মুছে ফেলা একটা secret ফিরিয়ে আনতে পারেন Source 26সোর্স 26। মুছে ফেলার জন্য চিহ্নিত secret-এর জন্য কোনো খরচ নেই Source 26সোর্স 26। আপনি একটা secret-এর একটা version সরাসরি মুছতে পারেন না Source 26সোর্স 26। কোনো application এখনো একটা secret ব্যবহার করে কি না তা না জানলে আপনি recovery window-এর সময় চেষ্টা করা access-এর জন্য একটা Amazon CloudWatch alarm বানাতে পারেন Source 26সোর্স 26। recovery window ছাড়া একটা secret মুছলে সেটা আর ফেরানো যায় না Source 26সোর্স 26।
Secrets Manager ব্যবহার করলে আপনি শুধু যা ব্যবহার করেন তার জন্য দাম দেন, কোনো ন্যূনতম বা setup খরচ ছাড়া Source 24সোর্স 24। বেশির ভাগ command shell-এ এমন সুবিধা আছে, যা আপনার secret ঝুঁকিতে ফেলতে পারে, যেমন logging আর সর্বশেষ দেওয়া command দেখার সুযোগ Source 27সোর্স 27। আপনার secret-এ প্রবেশ নিয়ন্ত্রণ করা IAM policy statement-এ সবচেয়ে কম সুবিধার (least privileged) নীতি ব্যবহার করুন Source 27সোর্স 27। আপনার secret সবচেয়ে কার্যকরভাবে ব্যবহার করতে সেগুলো cache করুন আর শুধু দরকারে হালনাগাদ করুন Source 27সোর্স 27।
Try it
The tutorial ran steps 1 to 3 on 2026-11-18 at 13:03 (+06) on Linux 7.0.0-43-generic, with Python 3.14.4, OpenSSL 3.5.5, aws-cli/2.41.0, and bash 5.3.9. Steps 1 and 2 are the tutorial's own models. They do not call AWS and need no AWS account. Step 3 needed no AWS account and no credentials in the tutorial's run. It uses the AWS CLI that step 1 of AWS Compute and Storage installs. In the tutorial's run, no AWS_ variable was set before the steps, and no ~/.aws folder existed before or after. The output is from the tutorial's run. Steps 4 to 6 are a read-along of AWS's own pages. The tutorial did not run them, because they need an account and can cost money.
1. Model the policy decision with Python. This is the tutorial's own code. It is a model of the rules that the AWS pages describe. It is not the AWS engine. It reads JSON policies with json.loads, which deserializes a JSON document to a Python object Source 32সোর্স 32. The two policies are those of the single-account example of AWS Source 11সোর্স 11, with one change. The identity policy of the tutorial lists two of the four actions of the AllowS3ListRead statement, and leaves out s3:GetAccountPublicAccessBlock and s3:ListAccessPoints Source 11সোর্স 11. Save this file as policy_model.py:
import json
import re
def wild(pattern):
"""IAM-style wildcards: * is any run of characters, ? is one character."""
return re.compile("^" + "".join(".*" if c == "*" else "." if c == "?" else re.escape(c) for c in pattern) + "$")
def as_list(value):
return [value] if isinstance(value, str) else list(value)
def applies(statement, principal, action, resource, from_resource_policy):
if from_resource_policy and principal not in as_list(statement.get("Principal", {}).get("AWS", [])):
return False
return (any(wild(a).match(action) for a in as_list(statement["Action"]))
and any(wild(r).match(resource) for r in as_list(statement["Resource"])))
def decide(principal, action, resource, identity_policies, resource_policy=None):
statements = [(s, False) for doc in identity_policies for s in doc["Statement"]]
if resource_policy:
statements += [(s, True) for s in resource_policy["Statement"]]
allowed = False
for statement, from_resource_policy in statements:
if not applies(statement, principal, action, resource, from_resource_policy):
continue
if statement["Effect"] == "Deny":
return "Deny (explicit deny: %s)" % statement.get("Sid", "no Sid")
allowed = True
return "Allow" if allowed else "Deny (implicit deny)"
CARLOS = "arn:aws:iam::123456789012:user/carlossalazar"
HOME, LOGS = "amzn-s3-demo-bucket-carlossalazar", "amzn-s3-demo-bucket-carlossalazar-logs"
identity = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Sid": "AllowS3ListRead", "Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListAllMyBuckets"], "Resource": "arn:aws:s3:::*"},
{"Sid": "AllowS3Self", "Effect": "Allow", "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]},
{"Sid": "DenyS3Logs", "Effect": "Deny", "Action": "s3:*", "Resource": "arn:aws:s3:::*log*"}]}""" % (HOME, HOME))
bucket = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Effect": "Allow", "Principal": {"AWS": "%s"}, "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]}]}""" % (CARLOS, HOME, HOME))
bucket_deny = json.loads(json.dumps(bucket))
bucket_deny["Statement"].append({"Sid": "DenyCarlos", "Effect": "Deny", "Principal": {"AWS": CARLOS}, "Action": "s3:*", "Resource": "arn:aws:s3:::%s/*" % HOME})
put = "s3:PutObject"
cases = [
("Carlos saves a file in the logs bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % LOGS, [identity], bucket),
("Carlos saves a file in his own bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket),
("Carlos saves a file in another bucket", CARLOS, "arn:aws:s3:::amzn-s3-demo-bucket-other/notes.txt", [identity], bucket),
("Someone else saves in Carlos's bucket", "arn:aws:iam::123456789012:user/someoneelse", "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, identity policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], None),
("Own bucket, bucket policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, bucket policy adds a Deny", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket_deny),
]
for label, principal, resource, identity_policies, resource_policy in cases:
print("%-40s %s" % (label + ":", decide(principal, put, resource, identity_policies, resource_policy)))Run it:
python3 policy_model.pyOutput of the tutorial's run:
Carlos saves a file in the logs bucket: Deny (explicit deny: DenyS3Logs)
Carlos saves a file in his own bucket: Allow
Carlos saves a file in another bucket: Deny (implicit deny)
Someone else saves in Carlos's bucket: Deny (implicit deny)
Own bucket, identity policy only: Allow
Own bucket, bucket policy only: Allow
Own bucket, bucket policy adds a Deny: Deny (explicit deny: DenyCarlos)Read each line with the AWS pages next to it:
- Logs bucket: AWS first checks for a
Denystatement that applies to the request, finds one, and Carlos is denied access Source 11সোর্স 11. - His own bucket: both the identity-based policy and the resource-based policy allow the request, so AWS allows it Source 11সোর্স 11.
- Another bucket: by default, all requests are implicitly denied Source 12সোর্স 12.
- Someone else: the bucket policy specifies that only the
carlossalazaruser can access the bucket Source 11সোর্স 11. In the model, the other user has no identity-based policy. - Identity policy only, and bucket policy only: if one of the two allows the request and the other doesn't, the request is still allowed Source 11সোর্স 11.
- A
Denyin the bucket policy: an explicit deny overrides an explicit allow Source 12সোর্স 12. The page says that if either policy explicitly denied the request, it would have been denied Source 11সোর্স 11.
For the first two lines, which are the example of the page, the model gave the answers that the text of the page gives. The other five requests are the tutorial's own, and the tutorial reasoned their expected answers from the cited sentences, not from AWS.
The model leaves a lot out. It reads no Condition, NotAction, or NotResource. It takes only one IAM user ARN in the Principal of a bucket policy. It has no permissions boundary, service control policy, resource control policy, session policy, root user, or request from another account. AWS evaluates all of these policy types that apply to a request Source 12সোর্স 12.
2. Model a key hierarchy with OpenSSL. This is the tutorial's own model of the key hierarchy that the AWS pages describe. It does not call AWS KMS. It follows envelope encryption, which is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key Source 19সোর্স 19. The root key of the model is a random value that stands in for a KMS key. In AWS KMS, KMS keys are created, managed, used, and deleted entirely within AWS KMS Source 17সোর্স 17.
openssl rand generates random bytes with a cryptographically secure pseudo random number generator Source 31সোর্স 31, and -hex shows the output as a hex string Source 31সোর্স 31. For openssl enc, the key given with -K must be a string of hex digits, and if only the key is specified, the IV must be given with -iv Source 30সোর্স 30. The option -d decrypts the input Source 30সোর্স 30. Using AES-256 in CBC mode is the tutorial's own choice. The command lists AES in CBC mode Source 30সোর্স 30. It does not support authenticated encryption modes like CCM and GCM Source 30সোর্স 30. So the model cannot tell whether a file was changed. Do not use it for real data.
Save this file as envelope.sh. It keeps the root keys and the data key in shell variables and never writes them to a file:
set -eu
mkdir envelope-demo && cd envelope-demo
ROOT_A=$(openssl rand -hex 32) # stands in for a KMS key
DATA=$(openssl rand -hex 32) # the data key
IV1=$(openssl rand -hex 16); IV2=$(openssl rand -hex 16); IV3=$(openssl rand -hex 16)
printf 'tester note: nothing secret here\n' > message.txt
# 1. seal the message with the data key, and the data key with the root key
openssl enc -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.txt -out message.enc
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -out datakey.enc
unset DATA
rm message.txt
echo "1. envelope: message.enc $(wc -c < message.enc) bytes, datakey.enc $(wc -c < datakey.enc) bytes"
# 2. open it: the root key opens the data key, and the data key opens the message
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -in datakey.enc)
echo "2. opened: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 3. "rotate": wrap the same data key under a new root key; message.enc is not touched
BEFORE=$(sha256sum < message.enc)
ROOT_B=$(openssl rand -hex 32)
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -out datakey.enc
unset DATA ROOT_A
if [ "$BEFORE" = "$(sha256sum < message.enc)" ]; then echo "3. message.enc is the same file after the re-wrap"; else echo "3. message.enc CHANGED"; fi
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -in datakey.enc)
echo "3. opened with the new root key: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 4. "delete" the root key: it was never written to a file, so nothing is left that opens datakey.enc
unset DATA ROOT_B
echo "4. no root key is left; files in the folder: $(ls | tr '\n' ' ')"Run it:
bash envelope.shOutput of the tutorial's run:
1. envelope: message.enc 48 bytes, datakey.enc 80 bytes
2. opened: tester note: nothing secret here
3. message.enc is the same file after the re-wrap
3. opened with the new root key: tester note: nothing secret here
4. no root key is left; files in the folder: datakey.enc message.enc - Line 1: the envelope is two files, the sealed message and the sealed data key. AWS says that you can safely store the encrypted data key alongside the encrypted data Source 19সোর্স 19. The model keeps the three IVs in shell variables and does not store them with the files.
- Line 2: the root key opens the data key, and the data key opens the message. The recipient first decrypts the encrypted key and then decrypts the message Source 19সোর্স 19. With AWS KMS, you first ask AWS KMS to decrypt the encrypted data key Source 20সোর্স 20.
- Line 3: the script wraps the same data key under a new root key. The message file is the same file after the re-wrap. AWS says that you can re-encrypt only the data keys instead of re-encrypting the raw data Source 19সোর্স 19. This is not a model of KMS key rotation. When you use a rotated KMS key to decrypt, AWS KMS uses the key material that was used to encrypt Source 21সোর্স 21, and the model drops the old root key. What both share is that key rotation does not re-encrypt any data Source 21সোর্স 21.
- Line 4: no root key is left. AWS says that after a KMS key is deleted, you can no longer decrypt the data that was encrypted under it Source 22সোর্স 22. The model has no waiting period and no way to cancel. AWS KMS requires a waiting period of 7 – 30 days Source 22সোর্স 22, and you can cancel key deletion before it ends Source 22সোর্স 22. The tutorial did not try to open
datakey.encafter step 4, so its output does not show that the data is unrecoverable.
3. Print the parameter templates of three commands. The command below first sets the same three environment variables as step 2 of AWS Compute and Storage. Choosing them is the tutorial's own choice. AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE name the files for configuration profiles and access keys, and AWS_EC2_METADATA_DISABLED disables the use of the EC2 instance metadata service (IMDS) Source 29সোর্স 29. The --generate-cli-skeleton option generates and displays a parameter template that you can customize and use as input on a command Source 28সোর্স 28. The three commands are the tutorial's own choice, and so is the filter. The four spaces in it keep nested names out.
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "iam create-role" "secretsmanager create-secret" "kms schedule-key-deletion"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneOutput of the tutorial's run:
== aws iam create-role
"Path": "",
"RoleName": "",
"AssumeRolePolicyDocument": "",
"Description": "",
"MaxSessionDuration": 0,
"PermissionsBoundary": "",
"Tags": [
== aws secretsmanager create-secret
"Name": "",
"ClientRequestToken": "",
"Description": "",
"KmsKeyId": "",
"SecretBinary": null,
"SecretString": "",
"Tags": [
"AddReplicaRegions": [
"ForceOverwriteReplicaSecret": true,
"Type": "",
"CrossAccountPrimaryARN": ""
== aws kms schedule-key-deletion
"KeyId": "",
"PendingWindowInDays": 0The tutorial did not check what the names in the templates mean against the API references. Two of them match an option in an example of the AWS pages, by name only. SecretString matches the option --secret-string in the create-secret example of AWS Source 25সোর্স 25. PendingWindowInDays matches the option --pending-window-in-days and the output field PendingWindowInDays in the schedule-key-deletion example of AWS Source 33সোর্স 33. For the waiting period, the console asks for a number of days between 7 and 30 Source 33সোর্স 33.
4. Read along: give an EC2 instance a role. This is AWS's own page. The tutorial did not run it. Cost warning. IAM, IAM Identity Center, and AWS STS are features of your AWS account offered at no additional charge Source 1সোর্স 1. You are charged only when you access other AWS services using your IAM users or AWS STS temporary security credentials Source 1সোর্স 1. An instance that you launch is billed as AWS Compute and Storage describes.
- An administrator creates the
Get-picsservice role and attaches the role to the EC2 instance Source 16সোর্স 16. - The role includes a permissions policy that grants read-only access to the specified S3 bucket Source 16সোর্স 16. It also includes a trust policy that allows the EC2 instance to assume the role and retrieve the temporary credentials Source 16সোর্স 16.
- A developer launches an EC2 instance and assigns the role to that instance Source 16সোর্স 16. To launch an instance with a role, the developer must have permission to launch EC2 instances and permission to pass IAM roles Source 16সোর্স 16.
- If you use the IAM console, the instance profile is managed for you Source 16সোর্স 16. If you use the AWS CLI or API, you must create the instance profile and assign the role to it as separate steps Source 16সোর্স 16.
- When the application runs, it obtains temporary security credentials from the EC2 instance metadata Source 16সোর্স 16. If the application caches them, it should get a refreshed set every hour, or at least 15 minutes before the current set expires Source 16সোর্স 16.
5. Read along: store a secret. This is AWS's own page. The tutorial did not run it. Cost warning. When you use Secrets Manager, you pay only for what you use, with no minimum or setup fees Source 24সোর্স 24. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24. Secrets Manager does not delete a secret at once, but after a recovery window of a minimum of seven days Source 26সোর্স 26. There is no charge for secrets that you have marked for deletion Source 26সোর্স 26.
- Open the Secrets Manager console and choose Store a new secret Source 25সোর্স 25.
- To store API keys, access tokens, or credentials that aren't for databases, choose Other type of secret Source 25সোর্স 25.
- Enter the secret as key/value pairs, or choose the Plaintext tab and enter it in any format Source 25সোর্স 25. The tutorial's own advice: use a made-up value, never a real credential.
- For Encryption key, choose the AWS KMS key that Secrets Manager uses to encrypt the secret value Source 25সোর্স 25. For most cases, choose
aws/secretsmanagerSource 25সোর্স 25. - Clean up at the end. In the list of secrets, choose the secret, and choose Actions and then Delete secret Source 26সোর্স 26. In Waiting period, enter the number of days to wait before the deletion becomes permanent, and choose Schedule deletion Source 26সোর্স 26.
6. Read along: schedule the deletion of a KMS key. This is AWS's own page. The tutorial did not run it. Cost warning. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. There is no charge for customer managed KMS keys that you manage and are scheduled for deletion Source 23সোর্স 23. If you cancel the deletion during the waiting period, the key will incur charges as though it was never scheduled for deletion Source 23সোর্স 23. The tutorial's own advice: do this only on a key that you made for the exercise. The page warns that deleting a KMS key is destructive and potentially dangerous Source 33সোর্স 33.
- In the navigation pane, choose Customer managed keys Source 33সোর্স 33. You cannot schedule the deletion of AWS managed keys or AWS owned keys Source 33সোর্স 33.
- Choose the checkbox next to the KMS key that you want to delete, and choose Key actions, Schedule key deletion Source 33সোর্স 33.
- For Waiting period (in days), enter a number of days between 7 and 30 Source 33সোর্স 33.
- Choose the check box next to I confirm that I want to schedule these keys for deletion Source 33সোর্স 33. The keys become immediately unusable for cryptographic operations Source 33সোর্স 33.
- AWS KMS records an entry in your AWS CloudTrail log when you schedule deletion of the KMS key and when the KMS key is actually deleted Source 33সোর্স 33.
সহজ English
The tutorial ran steps 1 to 3 on 2026-11-18 at 13:03 (+06) on Linux 7.0.0-43-generic, with Python 3.14.4, OpenSSL 3.5.5, aws-cli/2.41.0, and bash 5.3.9. Steps 1 and 2 are the tutorial's own models. They do not call AWS and need no AWS account. Step 3 needed no AWS account and no credentials in the tutorial's run. It uses the AWS CLI that step 1 of AWS Compute and Storage installs. In the tutorial's run, no AWS_ variable was set before the steps, and no ~/.aws folder existed before or after. The output is from the tutorial's run. Steps 4 to 6 are a read-along of AWS's own pages. The tutorial did not run them, because they need an account and can cost money.
1. Model the policy decision with Python. This is the tutorial's own code. It is a model of the rules that the AWS pages describe. It is not the AWS engine. It reads JSON policies with json.loads, which deserializes a JSON document to a Python object Source 32সোর্স 32. The two policies are those of the single-account example of AWS Source 11সোর্স 11, with one change. The identity policy of the tutorial lists two of the four actions of the AllowS3ListRead statement, and leaves out s3:GetAccountPublicAccessBlock and s3:ListAccessPoints Source 11সোর্স 11. Save this file as policy_model.py:
import json
import re
def wild(pattern):
"""IAM-style wildcards: * is any run of characters, ? is one character."""
return re.compile("^" + "".join(".*" if c == "*" else "." if c == "?" else re.escape(c) for c in pattern) + "$")
def as_list(value):
return [value] if isinstance(value, str) else list(value)
def applies(statement, principal, action, resource, from_resource_policy):
if from_resource_policy and principal not in as_list(statement.get("Principal", {}).get("AWS", [])):
return False
return (any(wild(a).match(action) for a in as_list(statement["Action"]))
and any(wild(r).match(resource) for r in as_list(statement["Resource"])))
def decide(principal, action, resource, identity_policies, resource_policy=None):
statements = [(s, False) for doc in identity_policies for s in doc["Statement"]]
if resource_policy:
statements += [(s, True) for s in resource_policy["Statement"]]
allowed = False
for statement, from_resource_policy in statements:
if not applies(statement, principal, action, resource, from_resource_policy):
continue
if statement["Effect"] == "Deny":
return "Deny (explicit deny: %s)" % statement.get("Sid", "no Sid")
allowed = True
return "Allow" if allowed else "Deny (implicit deny)"
CARLOS = "arn:aws:iam::123456789012:user/carlossalazar"
HOME, LOGS = "amzn-s3-demo-bucket-carlossalazar", "amzn-s3-demo-bucket-carlossalazar-logs"
identity = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Sid": "AllowS3ListRead", "Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListAllMyBuckets"], "Resource": "arn:aws:s3:::*"},
{"Sid": "AllowS3Self", "Effect": "Allow", "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]},
{"Sid": "DenyS3Logs", "Effect": "Deny", "Action": "s3:*", "Resource": "arn:aws:s3:::*log*"}]}""" % (HOME, HOME))
bucket = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Effect": "Allow", "Principal": {"AWS": "%s"}, "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]}]}""" % (CARLOS, HOME, HOME))
bucket_deny = json.loads(json.dumps(bucket))
bucket_deny["Statement"].append({"Sid": "DenyCarlos", "Effect": "Deny", "Principal": {"AWS": CARLOS}, "Action": "s3:*", "Resource": "arn:aws:s3:::%s/*" % HOME})
put = "s3:PutObject"
cases = [
("Carlos saves a file in the logs bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % LOGS, [identity], bucket),
("Carlos saves a file in his own bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket),
("Carlos saves a file in another bucket", CARLOS, "arn:aws:s3:::amzn-s3-demo-bucket-other/notes.txt", [identity], bucket),
("Someone else saves in Carlos's bucket", "arn:aws:iam::123456789012:user/someoneelse", "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, identity policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], None),
("Own bucket, bucket policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, bucket policy adds a Deny", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket_deny),
]
for label, principal, resource, identity_policies, resource_policy in cases:
print("%-40s %s" % (label + ":", decide(principal, put, resource, identity_policies, resource_policy)))Run it:
python3 policy_model.pyOutput of the tutorial's run:
Carlos saves a file in the logs bucket: Deny (explicit deny: DenyS3Logs)
Carlos saves a file in his own bucket: Allow
Carlos saves a file in another bucket: Deny (implicit deny)
Someone else saves in Carlos's bucket: Deny (implicit deny)
Own bucket, identity policy only: Allow
Own bucket, bucket policy only: Allow
Own bucket, bucket policy adds a Deny: Deny (explicit deny: DenyCarlos)Read each line with the AWS pages next to it:
- Logs bucket: AWS first checks for a
Denystatement that applies to the request, finds one, and Carlos is denied access Source 11সোর্স 11. - His own bucket: both the identity-based policy and the resource-based policy allow the request, so AWS allows it Source 11সোর্স 11.
- Another bucket: by default, all requests are implicitly denied Source 12সোর্স 12.
- Someone else: the bucket policy specifies that only the
carlossalazaruser can access the bucket Source 11সোর্স 11. In the model, the other user has no identity-based policy. - Identity policy only, and bucket policy only: if one of the two allows the request and the other doesn't, the request is still allowed Source 11সোর্স 11.
- A
Denyin the bucket policy: an explicit deny overrides an explicit allow Source 12সোর্স 12. The page says that if either policy explicitly denied the request, it would have been denied Source 11সোর্স 11.
For the first two lines, which are the example of the page, the model gave the answers that the text of the page gives. The other five requests are the tutorial's own, and the tutorial reasoned their expected answers from the cited sentences, not from AWS.
The model leaves a lot out. It reads no Condition, NotAction, or NotResource. It takes only one IAM user ARN in the Principal of a bucket policy. It has no permissions boundary, service control policy, resource control policy, session policy, root user, or request from another account. AWS evaluates all of these policy types that apply to a request Source 12সোর্স 12.
2. Model a key hierarchy with OpenSSL. This is the tutorial's own model of the key hierarchy that the AWS pages describe. It does not call AWS KMS. It follows envelope encryption, which is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key Source 19সোর্স 19. The root key of the model is a random value that stands in for a KMS key. In AWS KMS, KMS keys are created, managed, used, and deleted entirely within AWS KMS Source 17সোর্স 17.
openssl rand generates random bytes with a cryptographically secure pseudo random number generator Source 31সোর্স 31, and -hex shows the output as a hex string Source 31সোর্স 31. For openssl enc, the key given with -K must be a string of hex digits, and if only the key is specified, the IV must be given with -iv Source 30সোর্স 30. The option -d decrypts the input Source 30সোর্স 30. Using AES-256 in CBC mode is the tutorial's own choice. The command lists AES in CBC mode Source 30সোর্স 30. It does not support authenticated encryption modes like CCM and GCM Source 30সোর্স 30. So the model cannot tell whether a file was changed. Do not use it for real data.
Save this file as envelope.sh. It keeps the root keys and the data key in shell variables and never writes them to a file:
set -eu
mkdir envelope-demo && cd envelope-demo
ROOT_A=$(openssl rand -hex 32) # stands in for a KMS key
DATA=$(openssl rand -hex 32) # the data key
IV1=$(openssl rand -hex 16); IV2=$(openssl rand -hex 16); IV3=$(openssl rand -hex 16)
printf 'tester note: nothing secret here\n' > message.txt
# 1. seal the message with the data key, and the data key with the root key
openssl enc -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.txt -out message.enc
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -out datakey.enc
unset DATA
rm message.txt
echo "1. envelope: message.enc $(wc -c < message.enc) bytes, datakey.enc $(wc -c < datakey.enc) bytes"
# 2. open it: the root key opens the data key, and the data key opens the message
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -in datakey.enc)
echo "2. opened: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 3. "rotate": wrap the same data key under a new root key; message.enc is not touched
BEFORE=$(sha256sum < message.enc)
ROOT_B=$(openssl rand -hex 32)
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -out datakey.enc
unset DATA ROOT_A
if [ "$BEFORE" = "$(sha256sum < message.enc)" ]; then echo "3. message.enc is the same file after the re-wrap"; else echo "3. message.enc CHANGED"; fi
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -in datakey.enc)
echo "3. opened with the new root key: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 4. "delete" the root key: it was never written to a file, so nothing is left that opens datakey.enc
unset DATA ROOT_B
echo "4. no root key is left; files in the folder: $(ls | tr '\n' ' ')"Run it:
bash envelope.shOutput of the tutorial's run:
1. envelope: message.enc 48 bytes, datakey.enc 80 bytes
2. opened: tester note: nothing secret here
3. message.enc is the same file after the re-wrap
3. opened with the new root key: tester note: nothing secret here
4. no root key is left; files in the folder: datakey.enc message.enc - Line 1: the envelope is two files, the sealed message and the sealed data key. AWS says that you can safely store the encrypted data key alongside the encrypted data Source 19সোর্স 19. The model keeps the three IVs in shell variables and does not store them with the files.
- Line 2: the root key opens the data key, and the data key opens the message. The recipient first decrypts the encrypted key and then decrypts the message Source 19সোর্স 19. With AWS KMS, you first ask AWS KMS to decrypt the encrypted data key Source 20সোর্স 20.
- Line 3: the script wraps the same data key under a new root key. The message file is the same file after the re-wrap. AWS says that you can re-encrypt only the data keys instead of re-encrypting the raw data Source 19সোর্স 19. This is not a model of KMS key rotation. When you use a rotated KMS key to decrypt, AWS KMS uses the key material that was used to encrypt Source 21সোর্স 21, and the model drops the old root key. What both share is that key rotation does not re-encrypt any data Source 21সোর্স 21.
- Line 4: no root key is left. AWS says that after a KMS key is deleted, you can no longer decrypt the data that was encrypted under it Source 22সোর্স 22. The model has no waiting period and no way to cancel. AWS KMS requires a waiting period of 7 – 30 days Source 22সোর্স 22, and you can cancel key deletion before it ends Source 22সোর্স 22. The tutorial did not try to open
datakey.encafter step 4, so its output does not show that the data is unrecoverable.
3. Print the parameter templates of three commands. The command below first sets the same three environment variables as step 2 of AWS Compute and Storage. Choosing them is the tutorial's own choice. AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE name the files for configuration profiles and access keys, and AWS_EC2_METADATA_DISABLED disables the use of the EC2 instance metadata service (IMDS) Source 29সোর্স 29. The --generate-cli-skeleton option generates and displays a parameter template that you can customize and use as input on a command Source 28সোর্স 28. The three commands are the tutorial's own choice, and so is the filter. The four spaces in it keep nested names out.
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "iam create-role" "secretsmanager create-secret" "kms schedule-key-deletion"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneOutput of the tutorial's run:
== aws iam create-role
"Path": "",
"RoleName": "",
"AssumeRolePolicyDocument": "",
"Description": "",
"MaxSessionDuration": 0,
"PermissionsBoundary": "",
"Tags": [
== aws secretsmanager create-secret
"Name": "",
"ClientRequestToken": "",
"Description": "",
"KmsKeyId": "",
"SecretBinary": null,
"SecretString": "",
"Tags": [
"AddReplicaRegions": [
"ForceOverwriteReplicaSecret": true,
"Type": "",
"CrossAccountPrimaryARN": ""
== aws kms schedule-key-deletion
"KeyId": "",
"PendingWindowInDays": 0The tutorial did not check what the names in the templates mean against the API references. Two of them match an option in an example of the AWS pages, by name only. SecretString matches the option --secret-string in the create-secret example of AWS Source 25সোর্স 25. PendingWindowInDays matches the option --pending-window-in-days and the output field PendingWindowInDays in the schedule-key-deletion example of AWS Source 33সোর্স 33. For the waiting period, the console asks for a number of days between 7 and 30 Source 33সোর্স 33.
4. Read along: give an EC2 instance a role. This is AWS's own page. The tutorial did not run it. Cost warning. IAM, IAM Identity Center, and AWS STS are features of your AWS account offered at no additional charge Source 1সোর্স 1. You are charged only when you access other AWS services using your IAM users or AWS STS temporary security credentials Source 1সোর্স 1. An instance that you launch is billed as AWS Compute and Storage describes.
- An administrator creates the
Get-picsservice role and attaches the role to the EC2 instance Source 16সোর্স 16. - The role includes a permissions policy that grants read-only access to the specified S3 bucket Source 16সোর্স 16. It also includes a trust policy that allows the EC2 instance to assume the role and retrieve the temporary credentials Source 16সোর্স 16.
- A developer launches an EC2 instance and assigns the role to that instance Source 16সোর্স 16. To launch an instance with a role, the developer must have permission to launch EC2 instances and permission to pass IAM roles Source 16সোর্স 16.
- If you use the IAM console, the instance profile is managed for you Source 16সোর্স 16. If you use the AWS CLI or API, you must create the instance profile and assign the role to it as separate steps Source 16সোর্স 16.
- When the application runs, it obtains temporary security credentials from the EC2 instance metadata Source 16সোর্স 16. If the application caches them, it should get a refreshed set every hour, or at least 15 minutes before the current set expires Source 16সোর্স 16.
5. Read along: store a secret. This is AWS's own page. The tutorial did not run it. Cost warning. When you use Secrets Manager, you pay only for what you use, with no minimum or setup fees Source 24সোর্স 24. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24. Secrets Manager does not delete a secret at once, but after a recovery window of a minimum of seven days Source 26সোর্স 26. There is no charge for secrets that you have marked for deletion Source 26সোর্স 26.
- Open the Secrets Manager console and choose Store a new secret Source 25সোর্স 25.
- To store API keys, access tokens, or credentials that aren't for databases, choose Other type of secret Source 25সোর্স 25.
- Enter the secret as key/value pairs, or choose the Plaintext tab and enter it in any format Source 25সোর্স 25. The tutorial's own advice: use a made-up value, never a real credential.
- For Encryption key, choose the AWS KMS key that Secrets Manager uses to encrypt the secret value Source 25সোর্স 25. For most cases, choose
aws/secretsmanagerSource 25সোর্স 25. - Clean up at the end. In the list of secrets, choose the secret, and choose Actions and then Delete secret Source 26সোর্স 26. In Waiting period, enter the number of days to wait before the deletion becomes permanent, and choose Schedule deletion Source 26সোর্স 26.
6. Read along: schedule the deletion of a KMS key. This is AWS's own page. The tutorial did not run it. Cost warning. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. There is no charge for customer managed KMS keys that you manage and are scheduled for deletion Source 23সোর্স 23. If you cancel the deletion during the waiting period, the key will incur charges as though it was never scheduled for deletion Source 23সোর্স 23. The tutorial's own advice: do this only on a key that you made for the exercise. The page warns that deleting a KMS key is destructive and potentially dangerous Source 33সোর্স 33.
- In the navigation pane, choose Customer managed keys Source 33সোর্স 33. You cannot schedule the deletion of AWS managed keys or AWS owned keys Source 33সোর্স 33.
- Choose the checkbox next to the KMS key that you want to delete, and choose Key actions, Schedule key deletion Source 33সোর্স 33.
- For Waiting period (in days), enter a number of days between 7 and 30 Source 33সোর্স 33.
- Choose the check box next to I confirm that I want to schedule these keys for deletion Source 33সোর্স 33. The keys become immediately unusable for cryptographic operations Source 33সোর্স 33.
- AWS KMS records an entry in your AWS CloudTrail log when you schedule deletion of the KMS key and when the KMS key is actually deleted Source 33সোর্স 33.
বাংলা ব্যাখ্যা
টিউটোরিয়াল ১ থেকে ৩ নম্বর ধাপ চালিয়েছে 2026-11-18 তারিখে 13:03-এ (+06), Linux 7.0.0-43-generic-এ, Python 3.14.4, OpenSSL 3.5.5, aws-cli/2.41.0 আর bash 5.3.9 দিয়ে। ১ আর ২ নম্বর ধাপ টিউটোরিয়ালের নিজের model। এগুলো AWS-কে call করে না আর কোনো AWS account লাগে না। টিউটোরিয়ালের run-এ ৩ নম্বর ধাপে কোনো AWS account বা credential লাগেনি। এটা সেই AWS CLI ব্যবহার করে, যা AWS Compute and Storage-এর ১ নম্বর ধাপে install হয়। টিউটোরিয়ালের run-এ ধাপগুলোর আগে কোনো AWS_ variable সেট ছিল না, আর ~/.aws folder run-এর আগে বা পরে ছিল না। output টিউটোরিয়ালের run থেকে নেওয়া। ৪ থেকে ৬ নম্বর ধাপ AWS-এর নিজের page পাশাপাশি পড়ে যাওয়া। টিউটোরিয়াল সেগুলো চালায়নি, কারণ সেগুলোর জন্য account লাগে আর খরচ হতে পারে।
১. Python দিয়ে policy-র সিদ্ধান্তের model বানান। এটা টিউটোরিয়ালের নিজের code। AWS-এর page যে নিয়মগুলো বলে, এটা তার একটা model। এটা AWS-এর engine নয়। এটা json.loads দিয়ে JSON policy পড়ে, যা একটা JSON document-কে Python object-এ বদলায় Source 32সোর্স 32। দুটো policy AWS-এর একটা account-এর ভেতরের উদাহরণের policy-ই Source 11সোর্স 11, তবে একটা বদল আছে। টিউটোরিয়ালের identity policy-তে AllowS3ListRead statement-এর চারটা action-এর মধ্যে দুটো আছে, আর s3:GetAccountPublicAccessBlock ও s3:ListAccessPoints বাদ দেওয়া হয়েছে Source 11সোর্স 11। এই file-টা policy_model.py নামে save করুন:
import json
import re
def wild(pattern):
"""IAM-style wildcards: * is any run of characters, ? is one character."""
return re.compile("^" + "".join(".*" if c == "*" else "." if c == "?" else re.escape(c) for c in pattern) + "$")
def as_list(value):
return [value] if isinstance(value, str) else list(value)
def applies(statement, principal, action, resource, from_resource_policy):
if from_resource_policy and principal not in as_list(statement.get("Principal", {}).get("AWS", [])):
return False
return (any(wild(a).match(action) for a in as_list(statement["Action"]))
and any(wild(r).match(resource) for r in as_list(statement["Resource"])))
def decide(principal, action, resource, identity_policies, resource_policy=None):
statements = [(s, False) for doc in identity_policies for s in doc["Statement"]]
if resource_policy:
statements += [(s, True) for s in resource_policy["Statement"]]
allowed = False
for statement, from_resource_policy in statements:
if not applies(statement, principal, action, resource, from_resource_policy):
continue
if statement["Effect"] == "Deny":
return "Deny (explicit deny: %s)" % statement.get("Sid", "no Sid")
allowed = True
return "Allow" if allowed else "Deny (implicit deny)"
CARLOS = "arn:aws:iam::123456789012:user/carlossalazar"
HOME, LOGS = "amzn-s3-demo-bucket-carlossalazar", "amzn-s3-demo-bucket-carlossalazar-logs"
identity = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Sid": "AllowS3ListRead", "Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListAllMyBuckets"], "Resource": "arn:aws:s3:::*"},
{"Sid": "AllowS3Self", "Effect": "Allow", "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]},
{"Sid": "DenyS3Logs", "Effect": "Deny", "Action": "s3:*", "Resource": "arn:aws:s3:::*log*"}]}""" % (HOME, HOME))
bucket = json.loads("""{"Version": "2012-10-17", "Statement": [
{"Effect": "Allow", "Principal": {"AWS": "%s"}, "Action": "s3:*", "Resource": ["arn:aws:s3:::%s/*", "arn:aws:s3:::%s"]}]}""" % (CARLOS, HOME, HOME))
bucket_deny = json.loads(json.dumps(bucket))
bucket_deny["Statement"].append({"Sid": "DenyCarlos", "Effect": "Deny", "Principal": {"AWS": CARLOS}, "Action": "s3:*", "Resource": "arn:aws:s3:::%s/*" % HOME})
put = "s3:PutObject"
cases = [
("Carlos saves a file in the logs bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % LOGS, [identity], bucket),
("Carlos saves a file in his own bucket", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket),
("Carlos saves a file in another bucket", CARLOS, "arn:aws:s3:::amzn-s3-demo-bucket-other/notes.txt", [identity], bucket),
("Someone else saves in Carlos's bucket", "arn:aws:iam::123456789012:user/someoneelse", "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, identity policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], None),
("Own bucket, bucket policy only", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [], bucket),
("Own bucket, bucket policy adds a Deny", CARLOS, "arn:aws:s3:::%s/notes.txt" % HOME, [identity], bucket_deny),
]
for label, principal, resource, identity_policies, resource_policy in cases:
print("%-40s %s" % (label + ":", decide(principal, put, resource, identity_policies, resource_policy)))চালান:
python3 policy_model.pyটিউটোরিয়ালের run-এর output:
Carlos saves a file in the logs bucket: Deny (explicit deny: DenyS3Logs)
Carlos saves a file in his own bucket: Allow
Carlos saves a file in another bucket: Deny (implicit deny)
Someone else saves in Carlos's bucket: Deny (implicit deny)
Own bucket, identity policy only: Allow
Own bucket, bucket policy only: Allow
Own bucket, bucket policy adds a Deny: Deny (explicit deny: DenyCarlos)প্রতিটা লাইন AWS-এর page পাশে রেখে পড়ুন:
- Logs bucket: AWS আগে এমন একটা
Denystatement খোঁজে, যা request-টার ওপর প্রযোজ্য, একটা পায়, আর Carlos-এর প্রবেশ আটকানো হয় Source 11সোর্স 11। - তার নিজের bucket: identity-based policy আর resource-based policy দুটোই request-টা অনুমতি দেয়, তাই AWS সেটা অনুমতি দেয় Source 11সোর্স 11।
- অন্য bucket: by default সব request implicitly denied Source 12সোর্স 12।
- অন্য কেউ: bucket policy ঠিক করে, শুধু
carlossalazaruser-ই bucket-টায় প্রবেশ করতে পারবে Source 11সোর্স 11। model-এ অন্য user-এর কোনো identity-based policy নেই। - শুধু identity policy, আর শুধু bucket policy: দুটোর একটা request-টা অনুমতি দিলে আর অন্যটা না দিলেও request অনুমতি পায় Source 11সোর্স 11।
- bucket policy-তে একটা
Deny: explicit deny explicit allow-কে বাতিল করে দেয় Source 12সোর্স 12। page বলে, কোনো একটা policy request-টা explicit deny করলে সেটা আটকানো হতো Source 11সোর্স 11।
প্রথম দুই লাইনের জন্য, যা page-এর উদাহরণ, model সেই উত্তরই দিয়েছে, যা page-এর লেখায় আছে। বাকি পাঁচটা request টিউটোরিয়ালের নিজের, আর টিউটোরিয়াল সেগুলোর প্রত্যাশিত উত্তর ভেবেছে উদ্ধৃত বাক্য থেকে, AWS থেকে নয়।
model অনেক কিছু বাদ রাখে। এটা Condition, NotAction বা NotResource পড়ে না। এটা একটা bucket policy-র Principal-এ শুধু একটা IAM user ARN নেয়। এতে নেই permissions boundary, service control policy, resource control policy, session policy, root user বা অন্য account থেকে আসা request। AWS একটা request-এর ওপর প্রযোজ্য এই সব ধরনের policy evaluate করে Source 12সোর্স 12।
২. OpenSSL দিয়ে একটা key hierarchy-র model বানান। AWS-এর page যে key hierarchy বলে, এটা তার টিউটোরিয়ালের নিজের model। এটা AWS KMS-কে call করে না। এটা envelope encryption মেনে চলে, যা হলো plaintext data-কে একটা data key দিয়ে encrypt করা, তারপর সেই data key-কে অন্য একটা key দিয়ে encrypt করার চর্চা Source 19সোর্স 19। model-এর root key একটা এলোমেলো মান, যা একটা KMS key-র জায়গা নেয়। AWS KMS-এ KMS key পুরোপুরি AWS KMS-এর ভেতরেই তৈরি, পরিচালিত, ব্যবহৃত ও মুছে ফেলা হয় Source 17সোর্স 17।
openssl rand একটা cryptographically secure pseudo random number generator দিয়ে এলোমেলো byte বানায় Source 31সোর্স 31, আর -hex output-কে hex string হিসেবে দেখায় Source 31সোর্স 31। openssl enc-এর জন্য -K দিয়ে দেওয়া key শুধু hex digit-এর একটা string হতে হয়, আর শুধু key দিলে IV দিতে হয় -iv দিয়ে Source 30সোর্স 30। -d option input decrypt করে Source 30সোর্স 30। AES-256 CBC mode-এ ব্যবহার করা টিউটোরিয়ালের নিজের পছন্দ। command-টা CBC mode-এ AES-এর তালিকা দেয় Source 30সোর্স 30। এটা CCM বা GCM-এর মতো authenticated encryption mode সমর্থন করে না Source 30সোর্স 30। তাই model বলতে পারে না কোনো file বদলেছে কি না। আসল data-র জন্য এটা ব্যবহার করবেন না।
এই file-টা envelope.sh নামে save করুন। এটা root key আর data key shell variable-এ রাখে, কখনো file-এ লেখে না:
set -eu
mkdir envelope-demo && cd envelope-demo
ROOT_A=$(openssl rand -hex 32) # stands in for a KMS key
DATA=$(openssl rand -hex 32) # the data key
IV1=$(openssl rand -hex 16); IV2=$(openssl rand -hex 16); IV3=$(openssl rand -hex 16)
printf 'tester note: nothing secret here\n' > message.txt
# 1. seal the message with the data key, and the data key with the root key
openssl enc -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.txt -out message.enc
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -out datakey.enc
unset DATA
rm message.txt
echo "1. envelope: message.enc $(wc -c < message.enc) bytes, datakey.enc $(wc -c < datakey.enc) bytes"
# 2. open it: the root key opens the data key, and the data key opens the message
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_A" -iv "$IV2" -in datakey.enc)
echo "2. opened: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 3. "rotate": wrap the same data key under a new root key; message.enc is not touched
BEFORE=$(sha256sum < message.enc)
ROOT_B=$(openssl rand -hex 32)
printf '%s' "$DATA" | openssl enc -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -out datakey.enc
unset DATA ROOT_A
if [ "$BEFORE" = "$(sha256sum < message.enc)" ]; then echo "3. message.enc is the same file after the re-wrap"; else echo "3. message.enc CHANGED"; fi
DATA=$(openssl enc -d -aes-256-cbc -K "$ROOT_B" -iv "$IV3" -in datakey.enc)
echo "3. opened with the new root key: $(openssl enc -d -aes-256-cbc -K "$DATA" -iv "$IV1" -in message.enc)"
# 4. "delete" the root key: it was never written to a file, so nothing is left that opens datakey.enc
unset DATA ROOT_B
echo "4. no root key is left; files in the folder: $(ls | tr '\n' ' ')"চালান:
bash envelope.shটিউটোরিয়ালের run-এর output:
1. envelope: message.enc 48 bytes, datakey.enc 80 bytes
2. opened: tester note: nothing secret here
3. message.enc is the same file after the re-wrap
3. opened with the new root key: tester note: nothing secret here
4. no root key is left; files in the folder: datakey.enc message.enc - ১ নম্বর লাইন: envelope হলো দুটো file, সিল করা message আর সিল করা data key। AWS বলে, encrypted data key আপনি encrypted data-র পাশেই নিরাপদে রাখতে পারেন Source 19সোর্স 19। model তিনটা IV shell variable-এ রাখে, file-গুলোর সঙ্গে জমা রাখে না।
- ২ নম্বর লাইন: root key data key খোলে, আর data key message খোলে। যে গ্রহণ করে, সে আগে encrypted key decrypt করে, তারপর message decrypt করে Source 19সোর্স 19। AWS KMS দিয়ে আপনি আগে AWS KMS-কে encrypted data key decrypt করতে বলেন Source 20সোর্স 20।
- ৩ নম্বর লাইন: script একই data key-কে একটা নতুন root key দিয়ে মুড়ে দেয়। re-wrap-এর পর message file একই file থাকে। AWS বলে, কাঁচা data re-encrypt করার বদলে আপনি শুধু data key-গুলো re-encrypt করতে পারেন Source 19সোর্স 19। এটা KMS key rotation-এর model নয়। আপনি rotate হওয়া KMS key দিয়ে decrypt করলে AWS KMS সেই key material ব্যবহার করে, যা দিয়ে encrypt হয়েছিল Source 21সোর্স 21, আর model পুরোনো root key ফেলে দেয়। দুটোর মিল এটুকুই যে key rotation কোনো data re-encrypt করে না Source 21সোর্স 21।
- ৪ নম্বর লাইন: কোনো root key বাকি নেই। AWS বলে, একটা KMS key মুছে গেলে তার অধীনে encrypt হওয়া data আপনি আর decrypt করতে পারেন না Source 22সোর্স 22। model-এ কোনো অপেক্ষার সময় নেই আর বাতিল করার উপায়ও নেই। AWS KMS ৭ – ৩০ দিনের অপেক্ষার সময় দাবি করে Source 22সোর্স 22, আর সেটা শেষ হওয়ার আগে আপনি মুছে ফেলা বাতিল করতে পারেন Source 22সোর্স 22। টিউটোরিয়াল ৪ নম্বর ধাপের পর
datakey.encখোলার চেষ্টা করেনি, তাই এর output দেখায় না যে data ফেরানো যায় না।
৩. তিনটা command-এর parameter template ছাপুন। নিচের command প্রথমে AWS Compute and Storage-এর ২ নম্বর ধাপের মতোই তিনটা environment variable সেট করে। এগুলো বেছে নেওয়া টিউটোরিয়ালের নিজের পছন্দ। AWS_CONFIG_FILE আর AWS_SHARED_CREDENTIALS_FILE configuration profile আর access key রাখার file-এর নাম দেয়, আর AWS_EC2_METADATA_DISABLED EC2 instance metadata service (IMDS)-এর ব্যবহার বন্ধ করে Source 29সোর্স 29। --generate-cli-skeleton option একটা parameter template তৈরি করে দেখায়, যা আপনি নিজের মতো করে বদলে একটা command-এর input হিসেবে ব্যবহার করতে পারেন Source 28সোর্স 28। তিনটা command টিউটোরিয়ালের নিজের পছন্দ, ছাঁকনিও তাই। এতে থাকা চারটা space ভেতরের (nested) নাম বাদ রাখে।
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "iam create-role" "secretsmanager create-secret" "kms schedule-key-deletion"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneটিউটোরিয়ালের run-এর output:
== aws iam create-role
"Path": "",
"RoleName": "",
"AssumeRolePolicyDocument": "",
"Description": "",
"MaxSessionDuration": 0,
"PermissionsBoundary": "",
"Tags": [
== aws secretsmanager create-secret
"Name": "",
"ClientRequestToken": "",
"Description": "",
"KmsKeyId": "",
"SecretBinary": null,
"SecretString": "",
"Tags": [
"AddReplicaRegions": [
"ForceOverwriteReplicaSecret": true,
"Type": "",
"CrossAccountPrimaryARN": ""
== aws kms schedule-key-deletion
"KeyId": "",
"PendingWindowInDays": 0টিউটোরিয়াল template-এর নামগুলোর মানে API reference-এর সঙ্গে যাচাই করেনি। এর দুটো AWS-এর page-এর একটা উদাহরণের option-এর সঙ্গে মেলে, শুধু নামের মিল দেখে। SecretString মেলে AWS-এর create-secret উদাহরণের --secret-string option-এর সঙ্গে Source 25সোর্স 25। PendingWindowInDays মেলে AWS-এর schedule-key-deletion উদাহরণের --pending-window-in-days option আর PendingWindowInDays output field-এর সঙ্গে Source 33সোর্স 33। অপেক্ষার সময়ের জন্য console ৭ থেকে ৩০-এর মধ্যে একটা দিনের সংখ্যা চায় Source 33সোর্স 33।
৪. পাশাপাশি পড়ুন: একটা EC2 instance-কে role দেওয়া। এটা AWS-এর নিজের page। টিউটোরিয়াল এটা চালায়নি। খরচের সতর্কতা। IAM, IAM Identity Center আর AWS STS আপনার AWS account-এর এমন feature, যা বাড়তি খরচ ছাড়া দেওয়া হয় Source 1সোর্স 1। আপনি তখনই শুধু খরচ করেন, যখন আপনার IAM user বা AWS STS-এর অস্থায়ী security credential দিয়ে অন্য AWS service ব্যবহার করেন Source 1সোর্স 1। আপনি যে instance চালু করেন, তার বিল হয় AWS Compute and Storage-এ যেভাবে বলা আছে।
- একজন administrator
Get-picsservice role বানায় আর role-টা EC2 instance-এ attach করে Source 16সোর্স 16। - role-এ থাকে একটা permissions policy, যা নির্দিষ্ট S3 bucket-এ শুধু পড়ার প্রবেশাধিকার দেয় Source 16সোর্স 16। এতে একটা trust policy-ও থাকে, যা EC2 instance-কে role assume করে অস্থায়ী credential retrieve করতে দেয় Source 16সোর্স 16।
- একজন developer একটা EC2 instance চালু করে আর role-টা সেই instance-এ দেয় Source 16সোর্স 16। role সহ instance চালু করতে developer-এর EC2 instance চালু করার permission আর IAM role পাস করার permission লাগে Source 16সোর্স 16।
- আপনি IAM console ব্যবহার করলে instance profile আপনার হয়ে পরিচালিত হয় Source 16সোর্স 16। আপনি AWS CLI বা API ব্যবহার করলে instance profile বানানো আর তাতে role দেওয়া আলাদা ধাপে করতে হয় Source 16সোর্স 16।
- application চলার সময় সে EC2 instance metadata থেকে অস্থায়ী security credential পায় Source 16সোর্স 16। application সেগুলো cache করলে প্রতি ঘণ্টায়, বা চলমান সেটের মেয়াদ শেষ হওয়ার অন্তত ১৫ মিনিট আগে, তার একটা নতুন সেট নেওয়া উচিত Source 16সোর্স 16।
৫. পাশাপাশি পড়ুন: একটা secret রাখা। এটা AWS-এর নিজের page। টিউটোরিয়াল এটা চালায়নি। খরচের সতর্কতা। Secrets Manager ব্যবহার করলে আপনি শুধু যা ব্যবহার করেন তার জন্য দাম দেন, কোনো ন্যূনতম বা setup খরচ ছাড়া Source 24সোর্স 24। আপনি আপনার secret encrypt করতে নিজের KMS key বানালে AWS আপনার কাছ থেকে বর্তমান AWS KMS হারে খরচ নেয় Source 24সোর্স 24। Secrets Manager একটা secret সঙ্গে সঙ্গে মোছে না, মোছে কমপক্ষে সাত দিনের একটা recovery window-এর পর Source 26সোর্স 26। মুছে ফেলার জন্য চিহ্নিত secret-এর জন্য কোনো খরচ নেই Source 26সোর্স 26।
- Secrets Manager console খুলুন আর Store a new secret বেছে নিন Source 25সোর্স 25।
- API key, access token বা database-এর নয় এমন credential রাখতে Other type of secret বেছে নিন Source 25সোর্স 25।
- secret-টা key/value pair হিসেবে দিন, বা Plaintext tab বেছে নিয়ে যেকোনো format-এ দিন Source 25সোর্স 25। টিউটোরিয়ালের নিজের পরামর্শ: বানানো একটা মান ব্যবহার করুন, কখনো আসল credential নয়।
- Encryption key-র জন্য সেই AWS KMS key বেছে নিন, যা Secrets Manager secret-এর মান encrypt করতে ব্যবহার করে Source 25সোর্স 25। বেশির ভাগ ক্ষেত্রে
aws/secretsmanagerবেছে নিন Source 25সোর্স 25। - শেষে পরিষ্কার করুন। secret-এর তালিকায় secret-টা বেছে নিন, তারপর Actions আর Delete secret বেছে নিন Source 26সোর্স 26। Waiting period-এ মুছে ফেলা স্থায়ী হওয়ার আগে কত দিন অপেক্ষা করবেন তা দিন, আর Schedule deletion বেছে নিন Source 26সোর্স 26।
৬. পাশাপাশি পড়ুন: একটা KMS key মুছে ফেলার জন্য schedule করা। এটা AWS-এর নিজের page। টিউটোরিয়াল এটা চালায়নি। খরচের সতর্কতা। আপনার account-এ একটা customer managed key রাখার জন্য মাসিক খরচ আছে Source 18সোর্স 18। মুছে ফেলার জন্য schedule করা customer managed KMS key-র জন্য কোনো খরচ নেই Source 23সোর্স 23। আপনি অপেক্ষার সময়ে মুছে ফেলা বাতিল করলে key-টার জন্য এমনভাবে খরচ হয়, যেন সেটা কখনো মুছে ফেলার জন্য schedule করাই হয়নি Source 23সোর্স 23। টিউটোরিয়ালের নিজের পরামর্শ: এটা শুধু এমন key-তে করুন, যা আপনি এই অনুশীলনের জন্য বানিয়েছেন। page সতর্ক করে, একটা KMS key মুছে ফেলা ধ্বংসাত্মক আর সম্ভাব্য বিপজ্জনক Source 33সোর্স 33।
- navigation pane-এ Customer managed keys বেছে নিন Source 33সোর্স 33। আপনি AWS managed key বা AWS owned key মুছে ফেলার জন্য schedule করতে পারেন না Source 33সোর্স 33।
- যে KMS key মুছতে চান তার পাশের checkbox বেছে নিন, তারপর Key actions, Schedule key deletion বেছে নিন Source 33সোর্স 33।
- Waiting period (in days)-এর জন্য ৭ থেকে ৩০-এর মধ্যে একটা দিনের সংখ্যা দিন Source 33সোর্স 33।
- I confirm that I want to schedule these keys for deletion-এর পাশের check box বেছে নিন Source 33সোর্স 33। key-গুলো সঙ্গে সঙ্গে cryptographic operation-এর জন্য অব্যবহারযোগ্য হয়ে যায় Source 33সোর্স 33।
- আপনি KMS key মুছে ফেলার জন্য schedule করলে আর KMS key সত্যিই মুছে গেলে, AWS KMS আপনার AWS CloudTrail log-এ একটা entry রাখে Source 33সোর্স 33।
How a tester uses it
- Check the deny matrix, not only the happy path. A request is allowed only if a policy explicitly allows it Source 12সোর্স 12. An explicit deny overrides an explicit allow Source 12সোর্স 12. In one account, an
Allowin either the identity-based or the resource-based policy is enough for most resources Source 12সোর্স 12. - Use the simulator before you change a live policy. The IAM policy simulator shows how AWS would evaluate a request, without sending a real request to any AWS service Source 13সোর্স 13. Its results can differ from your live AWS environment Source 13সোর্স 13.
- Wait for IAM changes. IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. Be sure to verify that the changes have been propagated before production workflows depend on them Source 1সোর্স 1.
- Find long-term keys. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Credentials in the shared AWS credentials file are stored in plaintext Source 6সোর্স 6. Secrets Manager replaces hard-coded credentials with a runtime call Source 24সোর্স 24.
- Test with the role of the workload. AWS delivers the temporary credentials of an IAM role to a compute resource such as EC2 or Lambda Source 3সোর্স 3. After temporary credentials expire, AWS no longer recognizes them Source 5সোর্স 5. A caching application should get a refreshed set at least 15 minutes before the current set expires Source 16সোর্স 16.
- Check MFA on powerful identities. AWS recommends MFA for an IAM user or the root user Source 3সোর্স 3. The root user should be used only for tasks that require root-level permissions Source 7সোর্স 7.
- Check the life of a secret. A deleted secret stays recoverable until the recovery window ends Source 26সোর্স 26. A CloudWatch alarm can tell you about access attempts during the recovery window Source 26সোর্স 26.
- Check that rotation does not break the app. Rotating credentials no longer requires updating your applications and deploying changes to application clients Source 24সোর্স 24. Automatic rotation can run as often as every four hours Source 27সোর্স 27.
- Check data after a KMS key rotates. When you use the rotated KMS key to decrypt ciphertext, AWS KMS uses the key material that was used to encrypt it Source 21সোর্স 21. You can safely use a rotated KMS key in applications without code changes Source 21সোর্স 21. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21.
- Watch a KMS key that is pending deletion. A KMS key pending deletion cannot be used in any cryptographic operations Source 22সোর্স 22. A CloudWatch alarm can warn you if a person or application attempts to use the key during the waiting period Source 22সোর্স 22.
- Run policy checks on the policy text. AWS checks JSON policy syntax and grammar Source 14সোর্স 14. IAM Access Analyzer validates IAM policies against policy grammar and AWS best practices Source 15সোর্স 15.
সহজ English
- Check the deny matrix, not only the happy path. A request is allowed only if a policy explicitly allows it Source 12সোর্স 12. An explicit deny overrides an explicit allow Source 12সোর্স 12. In one account, an
Allowin either the identity-based or the resource-based policy is enough for most resources Source 12সোর্স 12. - Use the simulator before you change a live policy. The IAM policy simulator shows how AWS would evaluate a request, without sending a real request to any AWS service Source 13সোর্স 13. Its results can differ from your live AWS environment Source 13সোর্স 13.
- Wait for IAM changes. IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. Be sure to verify that the changes have been propagated before production workflows depend on them Source 1সোর্স 1.
- Find long-term keys. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Credentials in the shared AWS credentials file are stored in plaintext Source 6সোর্স 6. Secrets Manager replaces hard-coded credentials with a runtime call Source 24সোর্স 24.
- Test with the role of the workload. AWS delivers the temporary credentials of an IAM role to a compute resource such as EC2 or Lambda Source 3সোর্স 3. After temporary credentials expire, AWS no longer recognizes them Source 5সোর্স 5. A caching application should get a refreshed set at least 15 minutes before the current set expires Source 16সোর্স 16.
- Check MFA on powerful identities. AWS recommends MFA for an IAM user or the root user Source 3সোর্স 3. The root user should be used only for tasks that require root-level permissions Source 7সোর্স 7.
- Check the life of a secret. A deleted secret stays recoverable until the recovery window ends Source 26সোর্স 26. A CloudWatch alarm can tell you about access attempts during the recovery window Source 26সোর্স 26.
- Check that rotation does not break the app. Rotating credentials no longer requires updating your applications and deploying changes to application clients Source 24সোর্স 24. Automatic rotation can run as often as every four hours Source 27সোর্স 27.
- Check data after a KMS key rotates. When you use the rotated KMS key to decrypt ciphertext, AWS KMS uses the key material that was used to encrypt it Source 21সোর্স 21. You can safely use a rotated KMS key in applications without code changes Source 21সোর্স 21. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21.
- Watch a KMS key that is pending deletion. A KMS key pending deletion cannot be used in any cryptographic operations Source 22সোর্স 22. A CloudWatch alarm can warn you if a person or application attempts to use the key during the waiting period Source 22সোর্স 22.
- Run policy checks on the policy text. AWS checks JSON policy syntax and grammar Source 14সোর্স 14. IAM Access Analyzer validates IAM policies against policy grammar and AWS best practices Source 15সোর্স 15.
বাংলা ব্যাখ্যা
- শুধু ঠিকঠাক পথ নয়, deny matrix যাচাই করুন। একটা request অনুমতি পায় কেবল তখনই, যখন কোনো policy তাকে স্পষ্টভাবে অনুমতি দেয় Source 12সোর্স 12। explicit deny explicit allow-কে বাতিল করে দেয় Source 12সোর্স 12। একটা account-এর ভেতরে বেশির ভাগ resource-এর জন্য identity-based বা resource-based policy-র যেকোনো একটাতে একটা
Allow-ই যথেষ্ট Source 12সোর্স 12। - live policy বদলানোর আগে simulator ব্যবহার করুন। IAM policy simulator দেখায় AWS একটা request কীভাবে evaluate করত, কোনো AWS service-এ আসল request না পাঠিয়ে Source 13সোর্স 13। এর ফল আপনার live AWS environment-এর থেকে আলাদা হতে পারে Source 13সোর্স 13।
- IAM পরিবর্তনের জন্য অপেক্ষা করুন। IAM, অন্য অনেক AWS service-এর মতোই, eventually consistent Source 1সোর্স 1। production workflow এই পরিবর্তনের ওপর নির্ভর করার আগে নিশ্চিত হয়ে নিন যে পরিবর্তনগুলো ছড়িয়ে গেছে Source 1সোর্স 1।
- দীর্ঘমেয়াদি key খুঁজুন। আপনার application file-এ access key বা credential তথ্য রাখবেন না Source 6সোর্স 6। shared AWS credentials file-এ রাখা credential plaintext-এ থাকে Source 6সোর্স 6। Secrets Manager hard-coded credential-এর জায়গায় একটা runtime call বসায় Source 24সোর্স 24।
- workload-এর role দিয়ে test করুন। AWS একটা IAM role-এর অস্থায়ী credential EC2 বা Lambda-র মতো একটা compute resource-এ পৌঁছে দেয় Source 3সোর্স 3। অস্থায়ী credential-এর মেয়াদ শেষ হলে AWS আর সেগুলো চেনে না Source 5সোর্স 5। cache করা application-এর চলমান সেটের মেয়াদ শেষ হওয়ার অন্তত ১৫ মিনিট আগে একটা নতুন সেট নেওয়া উচিত Source 16সোর্স 16।
- ক্ষমতাবান identity-তে MFA যাচাই করুন। AWS একজন IAM user বা root user-এর জন্য MFA-র সুপারিশ করে Source 3সোর্স 3। root user ব্যবহার করা উচিত শুধু সেই কাজে, যার জন্য root-level permission লাগে Source 7সোর্স 7।
- একটা secret-এর জীবন যাচাই করুন। মুছে ফেলা একটা secret recovery window শেষ না হওয়া পর্যন্ত ফেরানো যায় Source 26সোর্স 26। একটা CloudWatch alarm আপনাকে recovery window-এর সময় চেষ্টা করা access-এর কথা জানাতে পারে Source 26সোর্স 26।
- rotation যেন app ভেঙে না দেয়, তা যাচাই করুন। credential rotate করতে আর আপনার application হালনাগাদ করা এবং application client-এ পরিবর্তন deploy করা লাগে না Source 24সোর্স 24। স্বয়ংক্রিয় rotation প্রতি চার ঘণ্টায়ও চলতে পারে Source 27সোর্স 27।
- KMS key rotate হওয়ার পর data যাচাই করুন। আপনি rotate হওয়া KMS key দিয়ে ciphertext decrypt করলে AWS KMS সেই key material ব্যবহার করে, যা দিয়ে ciphertext encrypt হয়েছিল Source 21সোর্স 21। আপনি rotate হওয়া KMS key code বদলানো ছাড়াই application-এ নিরাপদে ব্যবহার করতে পারেন Source 21সোর্স 21। Key rotation KMS key যে data রক্ষা করে, তার ওপর কোনো প্রভাব ফেলে না Source 21সোর্স 21।
- মুছে ফেলার অপেক্ষায় থাকা KMS key-র ওপর নজর রাখুন। মুছে ফেলার অপেক্ষায় থাকা KMS key কোনো cryptographic operation-এ ব্যবহার করা যায় না Source 22সোর্স 22। একটা CloudWatch alarm আপনাকে সাবধান করতে পারে, অপেক্ষার সময় কোনো মানুষ বা application key-টা ব্যবহারের চেষ্টা করলে Source 22সোর্স 22।
- policy-র লেখায় policy check চালান। AWS JSON policy-র syntax আর grammar পরীক্ষা করে Source 14সোর্স 14। IAM Access Analyzer IAM policy-কে policy grammar আর AWS best practice-এর সঙ্গে মিলিয়ে যাচাই করে Source 15সোর্স 15।
Common mistakes
- Using the root user every day. AWS strongly recommends that you don't use the root user for everyday tasks Source 1সোর্স 1.
- Putting long-term keys in code. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Do NOT include files that contain access keys or credential information in your project area Source 6সোর্স 6.
- Expecting a lost secret access key to come back. The secret access key can be retrieved only at the time you create it Source 6সোর্স 6. If you lose it, you must delete the access key and create a new one Source 6সোর্স 6.
- Expecting an IAM change to work at once. IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. AWS recommends that you do not include such changes in the critical, high-availability code paths of your application Source 1সোর্স 1.
- Expecting an Allow to beat a Deny. An explicit deny overrides an explicit allow Source 12সোর্স 12.
- Forgetting the default. By default, all requests are implicitly denied, with the exception of the AWS account root user, which has full access Source 12সোর্স 12.
- Granting more than the task needs. AWS managed policies might not grant least-privilege permissions for your specific use cases Source 3সোর্স 3.
- Packing several permissions into one statement. If you try to define multiple permissions in a single statement, your policy might not grant the access that you expect Source 9সোর্স 9.
- Adding a
Principalto an identity-based policy. If you are creating an IAM permissions policy to attach to a user or role, you cannot include this element Source 9সোর্স 9. - Treating the simulator as the last word. The policy simulator results can differ from your live AWS environment Source 13সোর্স 13.
- Believing that key rotation re-encrypts data. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21. It will not mitigate the effect of a compromised data key Source 21সোর্স 21.
- Deleting a KMS key that you may still need. After a KMS key is deleted, you can no longer decrypt the data that was encrypted under that KMS key Source 22সোর্স 22. If you are not sure, consider disabling the KMS key instead Source 22সোর্স 22.
- Forgetting what costs money. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24. When you turn on automatic rotation (except managed rotation), you are charged for the rotation function at the current Lambda rate Source 24সোর্স 24.
- Expecting a deleted secret to be gone at once. Secrets Manager does not immediately delete secrets Source 26সোর্স 26. A secret that you delete without a recovery window can't be recovered Source 26সোর্স 26.
- Typing a secret into a shell. Most command shells offer features that could compromise your secrets, such as logging and the ability to see the last entered command Source 27সোর্স 27.
- Using the OpenSSL model for real data.
openssl encdoes not support authenticated encryption modes like CCM and GCM Source 30সোর্স 30.
সহজ English
- Using the root user every day. AWS strongly recommends that you don't use the root user for everyday tasks Source 1সোর্স 1.
- Putting long-term keys in code. Do NOT put access keys or credential information in your application files Source 6সোর্স 6. Do NOT include files that contain access keys or credential information in your project area Source 6সোর্স 6.
- Expecting a lost secret access key to come back. The secret access key can be retrieved only at the time you create it Source 6সোর্স 6. If you lose it, you must delete the access key and create a new one Source 6সোর্স 6.
- Expecting an IAM change to work at once. IAM, like many other AWS services, is eventually consistent Source 1সোর্স 1. AWS recommends that you do not include such changes in the critical, high-availability code paths of your application Source 1সোর্স 1.
- Expecting an Allow to beat a Deny. An explicit deny overrides an explicit allow Source 12সোর্স 12.
- Forgetting the default. By default, all requests are implicitly denied, with the exception of the AWS account root user, which has full access Source 12সোর্স 12.
- Granting more than the task needs. AWS managed policies might not grant least-privilege permissions for your specific use cases Source 3সোর্স 3.
- Packing several permissions into one statement. If you try to define multiple permissions in a single statement, your policy might not grant the access that you expect Source 9সোর্স 9.
- Adding a
Principalto an identity-based policy. If you are creating an IAM permissions policy to attach to a user or role, you cannot include this element Source 9সোর্স 9. - Treating the simulator as the last word. The policy simulator results can differ from your live AWS environment Source 13সোর্স 13.
- Believing that key rotation re-encrypts data. Key rotation has no effect on the data that the KMS key protects Source 21সোর্স 21. It will not mitigate the effect of a compromised data key Source 21সোর্স 21.
- Deleting a KMS key that you may still need. After a KMS key is deleted, you can no longer decrypt the data that was encrypted under that KMS key Source 22সোর্স 22. If you are not sure, consider disabling the KMS key instead Source 22সোর্স 22.
- Forgetting what costs money. There is a monthly cost to have a customer managed key in your account Source 18সোর্স 18. If you create your own KMS keys to encrypt your secrets, AWS charges you at the current AWS KMS rate Source 24সোর্স 24. When you turn on automatic rotation (except managed rotation), you are charged for the rotation function at the current Lambda rate Source 24সোর্স 24.
- Expecting a deleted secret to be gone at once. Secrets Manager does not immediately delete secrets Source 26সোর্স 26. A secret that you delete without a recovery window can't be recovered Source 26সোর্স 26.
- Typing a secret into a shell. Most command shells offer features that could compromise your secrets, such as logging and the ability to see the last entered command Source 27সোর্স 27.
- Using the OpenSSL model for real data.
openssl encdoes not support authenticated encryption modes like CCM and GCM Source 30সোর্স 30.
বাংলা ব্যাখ্যা
- প্রতিদিন root user ব্যবহার করা। AWS জোর দিয়ে সুপারিশ করে, আপনি যেন প্রতিদিনের কাজে root user ব্যবহার না করেন Source 1সোর্স 1।
- code-এ দীর্ঘমেয়াদি key রাখা। আপনার application file-এ access key বা credential তথ্য রাখবেন না Source 6সোর্স 6। access key বা credential তথ্য আছে এমন file আপনার project এলাকায় রাখবেন না Source 6সোর্স 6।
- হারানো secret access key ফিরে আসবে আশা করা। secret access key শুধু তৈরির সময়ই retrieve করা যায় Source 6সোর্স 6। হারালে আপনাকে access key মুছে নতুন একটা বানাতে হয় Source 6সোর্স 6।
- IAM-এর পরিবর্তন সঙ্গে সঙ্গে কাজ করবে আশা করা। IAM, অন্য অনেক AWS service-এর মতোই, eventually consistent Source 1সোর্স 1। AWS সুপারিশ করে, আপনার application-এর জরুরি, high-availability code path-এ IAM-এর এমন পরিবর্তন রাখবেন না Source 1সোর্স 1।
- Allow, Deny-কে হারাবে আশা করা। explicit deny explicit allow-কে বাতিল করে দেয় Source 12সোর্স 12।
- default ভুলে যাওয়া। By default সব request implicitly denied হয়, শুধু AWS account root user বাদে, যার পূর্ণ প্রবেশাধিকার আছে Source 12সোর্স 12।
- কাজের চেয়ে বেশি permission দেওয়া। AWS managed policy আপনার নির্দিষ্ট ব্যবহারের জন্য least-privilege permission নাও দিতে পারে Source 3সোর্স 3।
- একটা statement-এ একাধিক permission ঠেসে দেওয়া। একটা statement-এ একাধিক permission ঠিক করতে গেলে আপনার policy আপনার প্রত্যাশিত access নাও দিতে পারে Source 9সোর্স 9।
- identity-based policy-তে
Principalযোগ করা। একটা user বা role-এ attach করার জন্য IAM permissions policy বানালে এই element রাখা যায় না Source 9সোর্স 9। - simulator-কে শেষ কথা ধরা। policy simulator-এর ফল আপনার live AWS environment-এর থেকে আলাদা হতে পারে Source 13সোর্স 13।
- key rotation data re-encrypt করে ভাবা। Key rotation KMS key যে data রক্ষা করে, তার ওপর কোনো প্রভাব ফেলে না Source 21সোর্স 21। এটা একটা ফাঁস হওয়া data key-র প্রভাব কমায় না Source 21সোর্স 21।
- যে KMS key আপনার এখনো লাগতে পারে, তা মুছে ফেলা। একটা KMS key মুছে গেলে সেই KMS key-র অধীনে encrypt হওয়া data আপনি আর decrypt করতে পারেন না Source 22সোর্স 22। আপনি নিশ্চিত না হলে বরং KMS key disable করার কথা ভাবুন Source 22সোর্স 22।
- কিসে খরচ হয় ভুলে যাওয়া। আপনার account-এ একটা customer managed key রাখার জন্য মাসিক খরচ আছে Source 18সোর্স 18। আপনি আপনার secret encrypt করতে নিজের KMS key বানালে AWS আপনার কাছ থেকে বর্তমান AWS KMS হারে খরচ নেয় Source 24সোর্স 24। আপনি স্বয়ংক্রিয় rotation চালু করলে (managed rotation বাদে) rotation function-এর জন্য বর্তমান Lambda হারে খরচ হয় Source 24সোর্স 24।
- মুছে ফেলা secret সঙ্গে সঙ্গে চলে যাবে আশা করা। Secrets Manager secret সঙ্গে সঙ্গে মুছে ফেলে না Source 26সোর্স 26। recovery window ছাড়া মুছে ফেলা secret আর ফেরানো যায় না Source 26সোর্স 26।
- একটা shell-এ secret টাইপ করা। বেশির ভাগ command shell-এ এমন সুবিধা আছে, যা আপনার secret ঝুঁকিতে ফেলতে পারে, যেমন logging আর সর্বশেষ দেওয়া command দেখার সুযোগ Source 27সোর্স 27।
- আসল data-র জন্য OpenSSL model ব্যবহার করা।
openssl encCCM বা GCM-এর মতো authenticated encryption mode সমর্থন করে না Source 30সোর্স 30।
What a tester can check
Tutorial advice
This list is the tutorial's own advice for a tester who works with IAM, KMS, and Secrets Manager.
- For every policy, write down three requests before you test: one that it allows, one that no policy mentions, and one that an explicit deny covers.
- Test a policy change in the simulator first, and then once in an account that you can throw away.
- After a policy change, wait and check that it took effect before you decide that it failed.
- Give each test workload its own role with the smallest set of permissions that it needs, and check that it fails when you remove one.
- Search the repository, the CI logs, and the container images for access keys before you test anything else.
- Use made-up secrets in practice. Never type a real credential into an exercise.
- Test the deletion of keys and secrets on ones that you made for the test, and put the cleanup in the same script that creates them.
- After a KMS key rotates, decrypt data that was encrypted before the rotation and data that was encrypted after it.
- Before you rotate a secret, find every place that reads it, and check that each place reads it again at run time.
- Keep the date, the tool versions, and the exact policy text with every test result.
- Use the models of this page to learn the rules, not as a test oracle for a real account.
- Look at the bill on the day after a test that created keys, secrets, or roles.
সহজ English
Tutorial advice
This list is the tutorial's own advice for a tester who works with IAM, KMS, and Secrets Manager.
- For every policy, write down three requests before you test: one that it allows, one that no policy mentions, and one that an explicit deny covers.
- Test a policy change in the simulator first, and then once in an account that you can throw away.
- After a policy change, wait and check that it took effect before you decide that it failed.
- Give each test workload its own role with the smallest set of permissions that it needs, and check that it fails when you remove one.
- Search the repository, the CI logs, and the container images for access keys before you test anything else.
- Use made-up secrets in practice. Never type a real credential into an exercise.
- Test the deletion of keys and secrets on ones that you made for the test, and put the cleanup in the same script that creates them.
- After a KMS key rotates, decrypt data that was encrypted before the rotation and data that was encrypted after it.
- Before you rotate a secret, find every place that reads it, and check that each place reads it again at run time.
- Keep the date, the tool versions, and the exact policy text with every test result.
- Use the models of this page to learn the rules, not as a test oracle for a real account.
- Look at the bill on the day after a test that created keys, secrets, or roles.
বাংলা ব্যাখ্যা
Tutorial advice
এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, এমন একজন tester-এর জন্য যিনি IAM, KMS আর Secrets Manager নিয়ে কাজ করেন।
- প্রতিটা policy-র জন্য test করার আগে তিনটা request লিখে রাখুন: যেটা সে অনুমতি দেয়, যেটার কথা কোনো policy বলে না, আর যেটা একটা explicit deny ঢেকে রাখে।
- একটা policy-র পরিবর্তন আগে simulator-এ test করুন, তারপর একবার এমন একটা account-এ, যা আপনি ফেলে দিতে পারেন।
- একটা policy বদলানোর পর ব্যর্থ ধরে নেওয়ার আগে অপেক্ষা করুন আর দেখুন পরিবর্তনটা কার্যকর হয়েছে কি না।
- প্রতিটা test workload-কে তার নিজের role দিন, যাতে যতটুকু permission লাগে ততটুকুই থাকে, আর একটা permission সরালে সেটা যে ব্যর্থ হয় তা যাচাই করুন।
- অন্য কিছু test করার আগে repository, CI log আর container image-এ access key খুঁজে দেখুন।
- অনুশীলনে বানানো secret ব্যবহার করুন। অনুশীলনে কখনো আসল credential টাইপ করবেন না।
- key আর secret মুছে ফেলার test করুন এমন key ও secret-এ, যা আপনি test-এর জন্য বানিয়েছেন, আর পরিষ্কারের কাজ রাখুন সেই একই script-এ, যা সেগুলো বানায়।
- একটা KMS key rotate হওয়ার পর rotation-এর আগে encrypt হওয়া data আর পরে encrypt হওয়া data দুটোই decrypt করে দেখুন।
- একটা secret rotate করার আগে যেসব জায়গা সেটা পড়ে সব খুঁজে বের করুন, আর যাচাই করুন প্রতিটা জায়গা সেটা run time-এ আবার পড়ে।
- প্রতিটা test-এর ফলের সঙ্গে তারিখ, tool-এর version আর policy-র হুবহু লেখা রাখুন।
- এই page-এর model-গুলো নিয়ম শেখার জন্য ব্যবহার করুন, একটা আসল account-এর test oracle হিসেবে নয়।
- যে test key, secret বা role বানিয়েছে, তার পরের দিন বিল দেখুন।
Key words
| Term | Meaning |
|---|---|
| IAM | A web service that helps you securely control access to AWS resources |
| Root user | The sign-in identity that you begin with when you create an AWS account; it has complete access to all AWS services and resources |
| IAM role | An IAM identity that you can create in your account that has specific permissions |
| Access key | A long-term credential for an IAM user or the AWS account root user |
| Temporary security credentials | Credentials that you can use AWS STS to create and provide to trusted users; they can be configured to last from a few minutes to several hours |
| MFA | Unique authentication from an AWS supported MFA mechanism, in addition to sign-in credentials |
| Policy | An object in AWS that, when associated with an identity or resource, defines their permissions |
| Identity-based policy | A JSON permissions policy document that controls what actions an identity can perform, on which resources, and under what conditions |
| Resource-based policy | A JSON policy document that you attach to a resource such as an Amazon S3 bucket |
| Trust policy | A policy that defines which principal entities can assume the role |
| Permissions boundary | It sets the maximum permissions that an identity-based policy can grant to an IAM entity |
| Explicit deny | A Deny statement that applies to the request; it overrides an explicit allow |
| Implicit deny | By default, all requests are implicitly denied, except for the root user, which has full access |
| Policy simulator | It shows how AWS would evaluate a request against the policies that you provide, without sending a real request to any AWS service |
| IAM Access Analyzer | It helps identify resources shared with an external entity, validates IAM policies, and generates IAM policies from access activity |
| AWS KMS | An AWS managed service that makes it easy to create and control the keys used to encrypt and sign your data |
| KMS key | A key that is created, managed, used, and deleted entirely within AWS KMS, and never leaves the service unencrypted |
| Customer managed key | A KMS key that you create; you can maintain its key policies, enable and disable it, rotate its cryptographic material, and schedule it for deletion; it has a monthly cost |
| Data key | A symmetric key that you can use to encrypt data; it is returned to you for use outside of AWS KMS |
| Envelope encryption | The practice of encrypting plaintext data with a data key, and then encrypting the data key under another key |
| Root key | The top-level plaintext key encryption key |
| Key rotation | New cryptographic material for a KMS key, every year by default when you enable automatic rotation; it has no effect on the data that the KMS key protects |
| Waiting period | Required for a KMS key that is scheduled for deletion: 7 – 30 days, and 30 days by default; you can cancel the deletion before it ends |
| Secrets Manager | It helps you manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles |
| Secret | A password, a set of credentials, an OAuth token, or other secret information that you store in an encrypted form in Secrets Manager |
| Recovery window | A minimum of seven days during which you can recover a secret that you deleted |
| Secret rotation | An automatic schedule for your secrets, as often as every four hours; Secrets Manager offers two strategies, Single user and Alternating users |