Note:<\/strong> \nThe section immediately below is deprecated and should be considered as an anti-pattern that should be avoided by security reasons. IAM Users and their static credentials should be avoided for accessing EC2 instances to reduce risks.<\/p>\n <\/div><\/div><\/div><\/div>\n\n\n\n
For the sake of security, we will create a new set of access keys.<\/s><\/p>\n\n\n\n
First, in the search bar in your AWS account, search for IAM<\/strong> and select Users<\/strong>.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nSelect the Create User option in the menu.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nHere you can name your User, and it is a good practice to leave the AWS Console option unchecked for security reasons. Once you are done you can click on Next<\/strong>.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nNext, whenever we create a new user, we need to select the permissions we will assign to it. In this example, we will give read-only access for EC2 instances, so that the user can list out instances and also AWS S3 full access, so we can create, view, and modify storage buckets.<\/s><\/p>\n\n\n\n
First, we will select the option Attach policies directly <\/strong>and search for AmazonEC2ReadOnlyAccess <\/strong>in the search bar. Once found, select it.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nAs mentioned above, we need to allow full access for AWS S3 so we can perform all operations.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nOnce done, click Next<\/strong>, <\/strong>and in the final step, you can review the settings and click Create User<\/strong>.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nYou can view the user’s data once it is created.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nWe can continue with the process by creating a new access key for our user.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nThe use case we will select in the menu is CLI.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nFinally, we need to accept the notice and click on Next<\/strong>.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nIn this step, you can add the description for this user and proceed with the Create access<\/strong> key option.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nYou will get all the information needed including access key ID and also the secret key.\u00a0<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nMake sure to follow security recommendations from AWS in order to increase the level of security for your AWS account.<\/s><\/p>\n\n\n\n
Now that we have a proper access key we will enter the following command:<\/s><\/p>\n\n\n\n\n
aws configure<\/p>\n<\/div><\/div>\n\n\n\n
Here we can enter our Access Key ID<\/strong>, Secret Key<\/strong>, Default region name<\/strong>, and Default output format<\/strong>.<\/s><\/p>\n\n\n\n <\/figure>\n\n\n\nIf you typically provision your instances in us-south-1, you can place that value. In this example, we are using eu-central-1 as our region.<\/s><\/p>\n\n\n\n
After the configuration, we can verify the status, and should be able to see our access key in the list.<\/s><\/p>\n\n\n\n\n
aws configure list<\/p>\n<\/div><\/div>\n\n\n\n <\/figure>\n\n\n\nStep 2: Basic AWS CLI Commands<\/h2>\n\n\n\n We can do multiple tasks with our CLI; for example, if we want to list out our instances, we can do so by running the following command:<\/p>\n\n\n\n
\n
aws ec2 describe-instances<\/p>\n<\/div><\/div>\n\n\n\n
We can see the following output:<\/p>\n\n\n\n <\/figure>\n\n\n\nNext, we can create a new S3 bucket in our AWS account:<\/p>\n\n\n\n
\n
aws s3 mb s3:\/\/jumpcloud-test-1<\/p>\n<\/div><\/div>\n\n\n\n <\/figure>\n\n\n\n From here, we can create a simple html file and upload it into our newly created S3 bucket:<\/p>\n\n\n\n