AWS
The tutorial provides instructions on setting up an API/access key clients have the option to integrate EMCP into their AWS environment.
Prerequisites
Access keys are long-term credentials for an IAM user or the AWS account root user. You can use access keys to sign programmatic requests to the AWS CLI or AWS API (directly or using the AWS SDK).
Access keys consist of two parts:
access key ID (e.g.,
AKIAIOSFODNN7EXAMPLE
)secret access key (e.g.,
JalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
)
You must use both the access key ID and secret access key together to authenticate your requests.
When you create an access key pair, save the access key ID and secret access key in a secure location. The secret access key is available only at the time you create it. If you lose your secret access key, you must delete the access key and create a new one.
Permissions required to manage access keys
To create access keys for your own IAM user, you must have the permissions from the following policy:
To update access keys for your own IAM user, you must have the permissions from the following policy:
Step-by-step guide
Create a new user and access key (console)
To grant a third party application access to your subscription, we need to create a new user and associate the access key with the user.
Create a new user in AWS IAM, do the following:
Select in the left Menu Access Management -> Users and click on Create user button next to the users table.
Enter a user name, such as EMCP API and press Next button. Leave option "Provide user access to the AWS Management Console" unchecked.
Select the permission option "Attach policies directly" and opt-in AWSPriceListServiceFullAccess, IAMReadOnlyAccess and AmazonEC2FullAccess. Press Next button.
Finalize the account creation and press Create user button.
Create an access key as follows:
Select the previously create user account.
Choose the tab Security Credentials.
Scroll down to Access Keys and click on Create access key button.
Select option "Third-party service You plan to use this access key to enable access for a third-party application or service that monitors or manages your AWS resources." and click on the checkbox to confirm to proceed to the creation.
(Optional) Set a description tag value for the access key. This adds a tag key-value pair to your IAM user. This can help you identify and update access keys later. The tag key is set to the access key id. The tag value is set to the access key description that you specify. When you are finished, choose Create access key.
On the Retrieve access keys page, choose either Show to reveal the value of your user's secret access key, or Download .csv file. This is your only opportunity to save your secret access key. After you've saved your secret access key in a secure location, choose Done.
Manage the Access Key
To deactivate an access key
In the Access keys section find the key you want to deactivate, then choose Actions, then choose Deactivate. When prompted for confirmation, choose Deactivate. A deactivated access key still counts toward your limit of two access keys.
To activate an access key
In the Access keys section, find the key to activate, then choose Actions, then choose Activate.
To delete an access key when you no longer need it
In the Access keys section, find the key you want to delete, then choose Actions, then choose Delete. Follow the instructions in the dialog to first Deactivate and then confirm the deletion. We recommend that you verify that the access key is no longer in use before you permanently delete it.
To create, modify, or delete the access keys of another IAM user (console)
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
Choose the name of the user whose access keys you want to manage, and then choose the Security credentials tab.
In the Access keys section, do any of the following:
To create an access key, choose Create access key. If the button is deactivated, then you must delete one of the existing keys before you can create a new one. On the Access key best practices & alternatives page, review the best practices and alternatives. Choose your use case to learn about additional options which can help you avoid creating a long-term access key. If you determine that your use case still requires an access key, choose Other and then choose Next. On the Retrieve access key page, choose Show to reveal the value of your user's secret access key. To save the access key ID and secret access key to a
.csv
file to a secure location on your computer, choose the Download .csv file button. When you create an access key for your user, that key pair is active by default, and your user can use the pair right away.To deactivate an active access key, choose Actions, and then choose Deactivate.
To activate an inactive access key, choose Actions, and then choose Activate.
To delete your access key, choose Actions, and then choose Delete. Follow the instructions in the dialog to first Deactivate and then confirm the deletion. AWS recommends that before you do this, you first deactivate the key and test that it’s no longer in use. When you use the AWS Management Console, you must deactivate your key before deleting it.
To list the access keys for an IAM user (console)
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
Choose the name of the intended user, and then choose the Security credentials tab. In the Access keys section, you will see the user's access keys and the status of each key displayed.
Note
Only the user's access key ID is visible. The secret access key can only be retrieved when the key is created.
To list the access key IDs for multiple IAM users (console)
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
If necessary, add the Access key ID column to the users table by completing the following steps:
In Manage columns, select Access key ID.
Choose Close to return to the list of users.
The Access key ID column shows each access key ID, followed by its state; for example, 23478207027842073230762374023 (Active) or 22093740239670237024843420327 (Inactive).
You can use this information to view and copy the access keys for users with one or two access keys. The column displays None for users with no access key.
Note
Only the user's access key ID and status is visible. The secret access key can only be retrieved when the key is created.
To find which IAM user owns a specific access key (console)
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
In the search box, type or paste the access key ID of the user you want to find.
If necessary, add the Access key ID column to the users table by completing the following steps:
In Manage columns, select Access key ID.
Choose Close to return to the list of users and confirm that the filtered user owns the specified access key.
Managing access keys (AWS CLI)
To manage the IAM user access keys from the AWS CLI, run the following commands.
To create an access key:
aws iam create-access-key
To deactivate or activate an access key:
aws iam update-access-key
To list a user's access keys:
aws iam list-access-keys
To determine when an access key was most recently used:
aws iam get-access-key-last-used
To delete an access key:
aws iam delete-access-key
Managing access keys (AWS API)
To manage the access keys of an IAM user from the AWS API, call the following operations.
To create an access key:
CreateAccessKey
To deactivate or activate an access key:
UpdateAccessKey
To list a user's access keys:
ListAccessKeys
To determine when an access key was most recently used:
GetAccessKeyLastUsed
To delete an access key:
DeleteAccessKey
Updating access keys
As a security best practice, we recommend that you update IAM user access keys when needed, such as when an employee leaves your company. IAM users can update their own access keys if they have been granted the necessary permissions.
Updating IAM user access keys (console)
You can update access keys from the AWS Management Console.
To update access keys for an IAM user without interrupting your applications (console)
While the first access key is still active, create a second access key.
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
Choose the name of the intended user, and then choose the Security credentials tab.
In the Access keys section, choose Create access key. On the Access key best practices & alternatives page, choose Other, then choose Next.
(Optional) Set a description tag value for the access key to add a tag key-value pair to this IAM user. This can help you identify and update access keys later. The tag key is set to the access key id. The tag value is set to the access key description that you specify. When you are finished, choose Create access key.
On the Retrieve access keys page, choose either Show to reveal the value of your user's secret access key, or Download .csv file. This is your only opportunity to save your secret access key. After you've saved your secret access key in a secure location, choose Done.
When you create an access key for your user, that key pair is active by default, and your user can use the pair right away. At this point, the user has two active access keys.
Update all applications and tools to use the new access key.
Determine whether the first access key is still in use by reviewing the Last used information for the oldest access key. One approach is to wait several days and then check the old access key for any use before proceeding.
Even if the Last used information indicates that the old key has never been used, we recommend that you do not immediately delete the first access key. Instead, choose Actions and then choose Deactivate to deactivate the first access key.
Use only the new access key to confirm that your applications are working. Any applications and tools that still use the original access key will stop working at this point because they no longer have access to AWS resources. If you find such an application or tool, you can reactivate the first access key. Then return to Step 3 and update this application to use the new key.
After you wait some period of time to ensure that all applications and tools have been updated, you can delete the first access key:
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
Choose the name of the intended user, and then choose the Security credentials tab.
In the Access keys section for the access key you want to delete, choose Actions, and then choose Delete. Follow the instructions in the dialog to first Deactivate and then confirm the deletion.
To determine which access keys need to be updated or deleted(console)
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
If necessary, add the Access key age column to the users table by completing the following steps:
In Manage columns, select Access key age.
Choose Close to return to the list of users.
The Access key age column shows the number of days since the oldest active access key was created. You can use this information to find users with access keys that might need to be updated or deleted. The column displays None for users with no access key.
Updating access keys (AWS CLI)
You can update access keys from the AWS Command Line Interface.
To update access keys without interrupting your applications (AWS CLI)
While the first access key is still active, create a second access key, which is active by default. Run the following command:
At this point, the user has two active access keys.
Update all applications and tools to use the new access key.
Determine whether the first access key is still in use by using this command:
One approach is to wait several days and then check the old access key for any use before proceeding.
Even if Step 3 indicates no use of the old key, we recommend that you do not immediately delete the first access key. Instead, change the state of the first access key to
Inactive
using this command:Use only the new access key to confirm that your applications are working. Any applications and tools that still use the original access key will stop working at this point because they no longer have access to AWS resources. If you find such an application or tool, you can switch its state back to
Active
to reactivate the first access key. Then return to Step 2 and update this application to use the new key.After you wait some period of time to ensure that all applications and tools have been updated, you can delete the first access key with this command:
Updating access keys (AWS API)
You can update access keys using the AWS API.
To update access keys without interrupting your applications (AWS API)
While the first access key is still active, create a second access key, which is active by default. Call the following operation:
At this point, the user has two active access keys.
Update all applications and tools to use the new access key.
Determine whether the first access key is still in use by calling this operation:
One approach is to wait several days and then check the old access key for any use before proceeding.
Even if Step 3 indicates no use of the old key, we recommend that you do not immediately delete the first access key. Instead, change the state of the first access key to
Inactive
calling this operation:Use only the new access key to confirm that your applications are working. Any applications and tools that still use the original access key will stop working at this point because they no longer have access to AWS resources. If you find such an application or tool, you can switch its state back to
Active
to reactivate the first access key. Then return to step Step 2 and update this application to use the new key.After you wait some period of time to ensure that all applications and tools have been updated, you can delete the first access key calling this operation:
Securing access keys
Anyone who has your access keys has the same level of access to your AWS resources that you do. Consequently, AWS goes to significant lengths to protect your access keys, and, in keeping with our shared-responsibility model, you should as well.
Expand the following sections for guidance to help you protect your access keys.
Note: Your organization may have different security requirements and policies than those described in this topic. The suggestions provided here are intended as general guidelines.
Remove (or don't generate) AWS account root user access keys
One of the best ways to protect your account is to not have access keys for your AWS account root user. Unless you must have root user access keys (which is rare), it is best not to generate them. Instead, create an administrative user in AWS IAM Identity Center for daily administrative tasks.
If you already have root user access keys for your account, we recommend the following: Find places in your applications where you are currently using access keys (if any), and replace the root user access keys with IAM user access keys. Then disable and remove the root user access keys.
Use temporary security credentials (IAM roles) instead of long-term access keys
In many scenarios, you don't need long-term access keys that never expire (as you have with an IAM user). Instead, you can create IAM roles and generate temporary security credentials. Temporary security credentials consist of an access key ID and a secret access key, but they also include a security token that indicates when the credentials expire.
Long-term access keys, such as those associated with IAM users and the root user, remain valid until you manually revoke them. However, temporary security credentials obtained through IAM roles and other features of the AWS Security Token Service expire after a short period of time. Use temporary security credentials to help reduce your risk in case credentials are accidentally exposed.
Use an IAM role and temporary security credentials in these scenarios:
You have an application or AWS CLI scripts running on an Amazon EC2 instance. Don't use access keys directly in your application. Don't pass access keys to the application, embed them in the application, or let the application read access keys from any source. Instead, define an IAM role that has appropriate permissions for your application and launch the Amazon Elastic Compute Cloud (Amazon EC2) instance with roles for EC2. Doing this associates an IAM role with the Amazon EC2 instance. This practice also enables the application to get temporary security credentials that it can in turn use to make programmatic calls to AWS. The AWS SDKs and the AWS Command Line Interface (AWS CLI) can get temporary credentials from the role automatically.
You need to grant cross-account access. Use an IAM role to establish trust between accounts, and then grant users in one account limited permissions to access the trusted account.
You have a mobile app. Don't embed access keys with the app, even in encrypted storage. Instead, use Amazon Cognito to manage user identities in your app. This service lets you authenticate users using Login with Amazon, Facebook, Google, or any OpenID Connect (OIDC)–compatible identity provider. You can then use the Amazon Cognito credentials provider to manage credentials that your app uses to make requests to AWS.
You want to federate into AWS and your organization supports SAML 2.0. If you work for an organization that has an identity provider that supports SAML 2.0, configure the provider to use SAML. You can use SAML to exchange authentication information with AWS and get back a set of temporary security credentials.
You want to federate into AWS and your organization has an on-premises identity store. If users can authenticate inside your organization, you can write an application that can issue them temporary security credentials for access to AWS resources.
Manage IAM user access keys properly
If you must create access keys for programmatic access to AWS, create them for IAM users, granting the users only the permissions they require.
Observe these precautions to help protect IAM user access keys:
Don't embed access keys directly into code. The AWS SDKs and the AWS Command Line Tools enable you to put access keys in known locations so that you don't have to keep them in code.
Put access keys in one of the following locations:
The AWS credentials file. The AWS SDKs and AWS CLI automatically use the credentials that you store in the AWS credentials file.
To store credentials for the AWS SDK for .NET and the AWS Tools for Windows PowerShell, we recommend that you use the SDK Store.
Environment variables. On a multi-tenant system, choose user environment variables, not system environment variables.
Use different access keys for different applications. Do this so that you can isolate the permissions and revoke the access keys for individual applications if they are exposed. Having separate access keys for different applications also generates distinct entries in AWS CloudTrail log files. This configuration makes it easier for you to determine which application performed specific actions.
Update access keys when needed. If there is a risk that the access key could be compromised, update the access key and delete the previous access key.
Remove unused access keys. If a user leaves your organization, remove the corresponding IAM user so that the user can no longer access your resources. To find out when an access key was last used, use the
GetAccessKeyLastUsed
API (AWS CLI command:aws iam get-access-key-last-used
).Use temporary credentials and configure multi-factor authentication for your most sensitive API operations. With IAM policies, you can specify which API operations a user is allowed to call. In some cases, you might want the additional security of requiring users to be authenticated with AWS MFA before you allow them to perform particularly sensitive actions. For example, you might have a policy that allows a user to perform the Amazon EC2
RunInstances
,DescribeInstances
, andStopInstances
actions. But you might want to restrict a destructive action likeTerminateInstances
and ensure that users can perform that action only if they authenticate with an AWS MFA device.
Access the mobile app using AWS access keys
You can access a limited set of AWS services and features using the AWS mobile app. The mobile app helps you support incident response while on the go.
You can sign in to the mobile app using your console password or your access keys. As a best practice, do not use root user access keys. Instead, we strongly recommend that in addition to using a password or biometric lock on your mobile device, you create an IAM user specifically for managing AWS resources using the mobile app. If you lose your mobile device, you can remove the IAM user's access.
To sign in using access keys (mobile app)
Open the app on your mobile device.
If this is the first time that you're adding an identity to the device, choose Add an identity and then choose Access keys.
If you have already signed in using another identity, choose the menu icon and choose Switch identity. Then choose Sign in as a different identity and then Access keys.
On the Access keys page, enter your information:
Access key ID – Enter your access key ID.
Secret access key – Enter your secret access key.
Identity name – Enter the name of the identity that will appear in the mobile app. This does not need to match your IAM user name.
Identity PIN – Create a personal identification number (PIN) that you will use for future sign-ins.
Note
If you enable biometrics for the AWS mobile app, you will be prompted to use your fingerprint or facial recognition for verification instead of the PIN. If the biometrics fail, you might be prompted for the PIN instead.
Choose Verify and add keys.
You can now access a select set of your resources using the mobile app.
Auditing access keys
You can review the AWS access keys in your code to determine whether the keys are from an account that you own. You can pass an access key ID using the aws sts get-access-key-info
AWS CLI command or the GetAccessKeyInfo
AWS API operation.
The AWS CLI and AWS API operations return the ID of the AWS account to which the access key belongs. Access key IDs beginning with AKIA
are long-term credentials for an IAM user or an AWS account root user. Access key IDs beginning with ASIA
are temporary credentials that are created using AWS STS operations. If the account in the response belongs to you, you can sign in as the root user and review your root user access keys. Then, you can pull a credentials report to learn which IAM user owns the keys. To learn who requested the temporary credentials for an ASIA
access key, view the AWS STS events in your CloudTrail logs.
For security purposes, you can review AWS CloudTrail logs to learn who performed an action in AWS. You can use the sts:SourceIdentity
condition key in the role trust policy to require users to specify an identity when they assume a role. For example, you can require that IAM users specify their own user name as their source identity. This can help you determine which user performed a specific action in AWS.
This operation does not indicate the state of the access key. The key might be active, inactive, or deleted. Active keys might not have permissions to perform an operation. Providing a deleted access key might return an error that the key doesn't exist.
Manual Configuration of Permissions
Make sure that the API key has rights to create resources. In IAM click on the user associated with the app
click on Add permissions and select Create inline policy
add permission fro each service from below list and click on next
choose a name for permission policy (e.g. emcp_policy)
Please verify that the app/account has also sufficient quotas in the datacenter regions of choice.
Last updated