Installing the AWS SAM CLI on macOS

Installing the AWS SAM CLI on macOS

https://docs.aws.amazon.com/zh_cn/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html

The following steps help you to install and configure the required prerequisites for using the AWS SAM CLI on your macOS host:

  1. Create an AWS account.
  2. Configure IAM permissions.
  3. Install the AWS CLI.
  4. Create an Amazon S3 bucket.
  5. Install Docker. Note: Docker is only a prerequisite for testing your application locally.
  6. Install Homebrew.
  7. Install the AWS SAM CLI.

Step 1: Create an AWS Account

If you don‘t already have an AWS account, see aws.amazon.com and choose Create an AWS Account. For detailed instructions, see Create and Activate an AWS Account.

Step 2: Create an IAM User with Administrator Permissions

If you don‘t already have an IAM user with administrator permissions, see Creating Your First IAM Admin User and Group in the IAM User Guide.

Step 3: Install and Configure the AWS CLI

If you don‘t already have the AWS CLI installed, this step shows you how install and configure it. You can check whether you have the AWS CLI installed by executing aws --version at a command line.

This section has two substeps: a) Install the AWS CLI using a bundled installer, and b) Configure the AWS CLI to use your credentials, default AWS Region, and desired output format.

Step 3a: Install the AWS CLI

We recommend that you use a bundled installer to avoid issues with existing Python installations when you have multiple versions.

The following commands assume that you want to install the AWS CLI for all users of a development host using sudo, and that the system default version of Python should be used. For alternative installation options, see Installing the AWS CLI.

curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

You should see the following output as the last line of a successful installation:

 You can now run: /usr/local/bin/aws --version
            

Step 3b: Configure the AWS CLI

After you‘ve verified installing the AWS CLI, you can configure it with your credentials, default AWS Region, and desired output format. To do this, you first create the necessary access keys by following these steps:

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane, choose Users.
  3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials tab.
  4. In the Access keys section, choose Create access key.
  5. To view the new access key pair, choose Show. You will not have access to the secret access key again after this dialog box closes. Your credentials will look something like this:
    • Access key ID: AKIAIOSFODNN7EXAMPLE
    • Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  6. To download the key pair, choose Download .csv file. Store the keys in a secure location. You will not have access to the secret access key again after this dialog box closes.

    Keep the keys confidential in order to protect your AWS account and never email them. Do not share them outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.

  7. After you download the .csv file, choose Close. When you create an access key, the key pair is active by default, and you can use the pair right away.

Configure the AWS CLI with your using the access keys you just created by executing the following command:

aws configure

When you‘re prompted, replace the following examples with your access keys:

 AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE                         # Enter your access key
 AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # Enter your secret key
 Default region name [None]: us-east-1                                  # Example regions: us-east-1, ap-east-1, eu-central-1, sa-east-1
 Default output format [None]: json                                     # Or ‘text‘
            

Additional configuration options are available in configuring the AWS CLI.

Step 4: Create an Amazon S3 Bucket

AWS SAM uses an Amazon S3 bucket in your AWS account as a repository to store deployment artifacts. To use the package and deployment functionality of AWS SAM, you must have an Amazon S3 bucket in the Region that you‘re working in.

If you need to create an Amazon S3 bucket, you can run the following command:

aws s3 mb s3://bucketname --region region # Example regions: us-east-1, ap-east-1, eu-central-1, sa-east-1

You should see the following output for a successfully created Amazon S3 bucket:

 make_bucket: bucketname
        

Remember to keep track of your Amazon S3 bucket name, because you need it to package your serverless application.

Step 5: Install Docker

Note

Docker is only a prerequisite for testing your application locally and to build deployment packages using the --use-container flag. You may skip this section or install Docker at a later time if you do not plan to use these features initially.

Docker is an application that runs containers on your macOS machines. AWS SAM provides a local environment that‘s similar to AWS Lambda to use as a Docker container. You can use this container to build, test, and debug your serverless applications.

You must have Docker installed and working to be able to run serverless projects and functions locally with the AWS SAM CLI. The AWS SAM CLI uses the DOCKER_HOST environment variable to contact the Docker daemon. The following steps describe how to install, configure, and verify a Docker installation to work with the AWS SAM CLI.

  1. Install Docker

    The AWS SAM CLI supports Docker running on macOS Sierra 10.12 or above. To install Docker see Install Docker Desktop for Mac.

  2. Configure your shared drives

    The AWS SAM CLI requires that the project directory, or any parent directory, is listed in a shared drive. To share drives on macOS, see File sharing.

  3. Verify the installation

    After Docker is installed, verify that it‘s working. Also confirm that you can run Docker commands from the AWS SAM CLI (for example, docker ps). You don‘t need to install, fetch, or pull any containers––the AWS SAM CLI does this automatically as required.

If you run into issues installing Docker, see the Docker installation guide for troubleshooting tips.

Step 6: Install Homebrew

The recommended approach for installing the AWS SAM CLI on macOS is to use the Homebrew package manager. For more information about Homebrew, see Homebrew Documentation.

To install Homebrew, run the following and follow the prompts:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Verify that Homebrew is installed:

brew --version

You should see output like the following on successful installation of Homebrew:

 Homebrew 2.1.6
 Homebrew/homebrew-core (git revision ef21; last commit 2019-06-19)
        

Step 7: Install the AWS SAM CLI

Follow these steps to install the AWS SAM CLI using Homebrew:

brew tap aws/tap
brew install aws-sam-cli

Verify that the AWS SAM CLI is installed to the following location:

Verify the installation:

sam --version

You should see output like the following after successful installation of the AWS SAM CLI:

 SAM CLI, version 0.19.0

You‘re now ready to start development.

Next Steps

You‘re now ready to begin building your own serverless applications using AWS SAM! If you want to start with sample serverless applications, choose one of the following links:

原文地址:https://www.cnblogs.com/cloudrivers/p/11526767.html

时间: 2024-08-04 10:50:25

Installing the AWS SAM CLI on macOS的相关文章

Installing the AWS Toolkit for Visual Studio Code

https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html Installing the AWS Toolkit for Visual Studio Code This section describes how to install the AWS Toolkit for Visual Studio Code. Prerequisites Required Before you can install

AWS S3 CLI的权限bug

使用AWS CLI在S3上创建了一个bucket,上传文件的时候报以下错误: A client error (AccessDenied) occurred when calling the CreateMultipartUpload operation: Anonymous users cannot initiate multipart uploads. Please authenticate. 执行命令:aws s3 ls s3://mybucket-1 同样提示权限错误. 之前使用AWS C

AWS学习笔记(一)--CLI基础知识(测试)

Installing the AWS CLI Install the AWS CLI Using pip on linux1) Install python---Check to see if Python is already installed---$ python --version---Install python---$ sudo yum install python 2) Install pip---check pip---$ pip -V---install pip---$ cur

从零开始设置用于深度学习的AWS服务器

自己的电脑显卡实在不给力,打算使用AWS的带GPU服务器进行云端计算. 首先到 https://amazonaws-china.com/ 右上角点击sign up注册账号,这里注意需要信用卡认证. 注册成功后需要申请GPU服务器,到 aws.amazon.com/contact-us/ec2-request 选择service limit increase,地区,之后选择服务器类型,在这里我们推荐p2.xlarge,价格适中. 之后选择limit value设置为1. 提交后等待1-2天即可通过

AWS之搭建深度学习主机

B.G 至2017.11 GPU选型:(参考知乎.CSDN) 高性价比的两款:GTX1080ti, Titan X --通常调试算法  i7CPU+32G内存+SSD+2*GPU(单块显存>6G),总计成本2.7 - 4w+RMB 土豪系列:Tesla K80, M40 云:(每小时成本高于物理机,优势是托管环境系统) AWS.UClound 阿里云HPC 一.准备工作 Amazon账号   在AWS上配置深度学习主机 AWS 命令行界面 (CLI)    https://aws.amazon.

重新开始继续准备AWS Dev认证考试:AWS Lambda 环境变量

利用 Lambda 函数的环境变量,您可以将设置动态传递到函数代码和库,而无需对代码进行任何更改.环境变量是您使用 AWS Lambda 控制台.AWS Lambda CLI 或 AWS Lambda 开发工具包作为函数配置的一部分创建并修改的密钥值对.AWS Lambda 随后会使用相应语言所支持的标准 API(如适用于 Node.js 函数的 process.env 将这些密钥值对提供给您的 Lambda 函数代码. 您可以使用环境变量帮助库了解以下信息:安装文件的目录.存储输出的位置.存储

AWS EC2避免误删软件包和数据的方法:取消“终止删除”默认配置

本文介绍AWS在终止实例的时候如何保留根卷,避免误删软件包和数据. 作者:光环云 尹晓征 在aws控制台创建EC2的时候,我们在添加存储步骤中,如果使用默认配置的情况下,“终止时删除”配置默认是被选中的,就是说在这个实例被终止的时候,所挂载的这个EBS卷也同时会被删除:这样带来的影响就是我们在这个卷中所配置的软件包或者存储的数据也就直接被删除了. 但是很不幸,aws的web管理控制台并没有选项取消这个默认配置,那么我们有没有方案能够满足这个需求呢?答案是有的,就是需要通过aws的cli命令行工具

CNCF LandScape Summary

CNCF Cloud Native Interactive Landscape 1. App Definition and Development 1. Database Vitess:itess is a database clustering system for horizontal scaling of MySQL. Apache CarbonData:Apache CarbonData is an indexed columnar data format for fast analyt

什么是Docker

Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. Docker is also a company that promotes and evolves this technology, working in collaborat