
AWS CLI
Enough with this theoretical rubbish. Its time to get practical!
What is the AWS CLI
đŠī¸ The AWS CLI is a command-line interface for interacting with Amazon Web Services.
đ¨âđģ It can be used to manage AWS resources, deploy applications, and automate common tasks.
đĒ With the AWS CLI, you have the power of Amazon's cloud at your fingertips!
đ Ready to unleash the power of AWS? Lets give it ago.
Lets set it up!
đ Step 1: Open a terminal window on your MacOS.
đ Step 2: Install the AWS CLI by running the following command:
brew install awscliđ Step 3: Verify that the AWS CLI is installed correctly by running the following command:
aws --versionđ Step 4: Configure the AWS CLI by running the following command:
aws configuređ Step 5: You will be prompted to enter your AWS access key ID, secret access key, default region name, and default output format. Follow the prompts to complete the configuration. This will take some exploring on your part, so google it if you have to đ. It may also require a IAM role to be set up for you based on your configuration, so you will have to request for it, or make one yourself. (IK a pain)
đ Step 6: You're all set! Now you can start using the AWS CLI to manage your AWS resources and automate tasks.
Okay, so what can you do with the AWS CLI? đ¤
With the AWS CLI, you can do all sorts of cool things! Here are just a few examples:
đ Deploy applications: You can use the AWS CLI to deploy your applications to AWS services such as Elastic Beanstalk, Lambda, and EC2.
đĻ Manage S3 buckets: You can use the AWS CLI to create, delete, and manage S3 buckets.
đ Manage security: You can use the AWS CLI to manage IAM users, groups, and policies to control access to your AWS resources.
đ Analyze data: You can use the AWS CLI to analyze data using services such as Amazon Athena, Amazon Redshift, and Amazon EMR.
đ Monitor your resources: You can use the AWS CLI to monitor your AWS resources using services such as Amazon CloudWatch and Amazon SNS.
đ Example: Uploading your code as a ZIP to be run on a Lambda function.
To upload your code as a ZIP to be run on a Lambda function, you can use the following AWS CLI commands:
- First, create a ZIP file of your code:
zip function.zip index.js
- Next, create a new Lambda function with the following command:
aws lambda create-function --function-name my-function --runtime nodejs14.x --zip-file fileb://function.zip --handler index.handler --role arn:aws:iam::123456789012:role/lambda-roleMake sure to replace my-function with the name of your function, nodejs14.x with the appropriate runtime, function.zip with the name of your ZIP file, index.handler with the name of your handler function, and arn:aws:iam::123456789012:role/lambda-role with the ARN of the IAM role you want to use.
- Finally, test your function with the following command:
aws lambda invoke --function-name my-function --payload '{"test": "data"}' output.json
This will invoke your Lambda function with the test data and store the output in output.json.
There you have it! With just a few AWS CLI commands, you can deploy your code to Lambda and start running it in the cloud. đ