|
3 | 3 | This repository is a deployable example demonstrating how to package and deploy |
4 | 4 | a Swift based Lambda to AWS. |
5 | 5 |
|
6 | | -Steps to deploy this sample to ASW: |
| 6 | +Steps to deploy this sample to AWS: |
7 | 7 |
|
8 | 8 | * Login to AWS Console and create an AWS Lambda with the following settings: |
9 | 9 | * Runtime: Custom runtime |
@@ -53,3 +53,63 @@ Steps to deploy this sample to ASW: |
53 | 53 | "error": "fatal" |
54 | 54 | } |
55 | 55 | `` |
| 56 | + |
| 57 | +### Deploy to AWS using AWS Serverless Application Model |
| 58 | + |
| 59 | +AWS [Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM) is an open-source framework for building serverless applications. This framework allows you to easily deploy other AWS resources and more complex deployment mechanisms such a CI pipelines. |
| 60 | + |
| 61 | +***Note:*** Deploying using SAM will automatically create resources within your AWS account. Charges may apply for these resources. |
| 62 | + |
| 63 | +To use SAM to deploy this sample to AWS- |
| 64 | + |
| 65 | +1. Install the AWS CLI by following the instructions at https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html |
| 66 | + |
| 67 | +2. Install SAM CLI by following the instructions at https://aws.amazon.com/serverless/sam/ |
| 68 | + |
| 69 | +3. Build, package and deploy the Lambda |
| 70 | + |
| 71 | + ``` |
| 72 | + ./scripts/sam-deploy.sh --guided |
| 73 | + ``` |
| 74 | + |
| 75 | +The script will ask you which sample lambda you wish to deploy. It will then guide you through the SAM setup process. |
| 76 | + |
| 77 | + ``` |
| 78 | + Setting default arguments for 'sam deploy' |
| 79 | + ========================================= |
| 80 | + Stack Name [sam-app]: swift-aws-lambda-runtime-sample |
| 81 | + AWS Region [us-east-1]: <your-favourite-region> |
| 82 | + #Shows you resources changes to be deployed and require a 'Y' to initiate deploy |
| 83 | + Confirm changes before deploy [y/N]: Y |
| 84 | + #SAM needs permission to be able to create roles to connect to the resources in your template |
| 85 | + Allow SAM CLI IAM role creation [Y/n]: Y |
| 86 | + Save arguments to samconfig.toml [Y/n]: Y |
| 87 | + ``` |
| 88 | + |
| 89 | +If you said yes to confirm changes, SAM will ask you to accept changes to the infratructure you are setting up. For more on this, see [Cloud Formation](https://aws.amazon.com/cloudformation/). |
| 90 | + |
| 91 | +The sam-deploy script passes through any parameters to the SAM deploy command. |
| 92 | + |
| 93 | +4. Subsequent deploys can just use the command; minus the guided parameter- |
| 94 | + |
| 95 | + ``` |
| 96 | + ./scripts/sam-deploy.sh |
| 97 | + ``` |
| 98 | + |
| 99 | +The script will ask you which sample lambda you wish to deploy. You are deploy a different sample lambda, the deploy process will pull down the previous lambda. |
| 100 | + |
| 101 | +SAM will still ask you to confirm changes if you said yes to that initially. |
| 102 | + |
| 103 | +5. Testing |
| 104 | + |
| 105 | +For the API Gateway sample: |
| 106 | + |
| 107 | +The SAM template will provide an output labelled `LambdaApiGatewayEndpoint` which you can use to test the Lambda. For example- |
| 108 | + |
| 109 | + ``` |
| 110 | + curl <<LambdaApiGatewayEndpoint>> |
| 111 | + ``` |
| 112 | + |
| 113 | +***Warning:*** This SAM template is only intended as a sample and creates a publically accessible http endpoint. |
| 114 | + |
| 115 | +For all other samples use the AWS Lambda console. |
0 commit comments