diff --git a/.github/aws-config.yml b/.github/aws-config.yml new file mode 100644 index 0000000..60f0df5 --- /dev/null +++ b/.github/aws-config.yml @@ -0,0 +1,43 @@ +--- + +########################################################## +# AWS Configuration file for NodeJS Deploy GitHub Action # +# # +# NOTE: This file holds the variables needed # +# to configure the GitHub Deploy NodeJS # +# on AWS Serverless # +# # +# This file needs to be in the location: # +# - .github/aws-config.yml # +# in your repository to be parsed at run time # +########################################################## + +######################################## +# AWS S3 Bucket for package and deploy # +######################################## +# NOTE: This bucket must exist before the GitHub Action, and match the name of your S3 bucket on Amazon +s3_bucket: githubactions-training + +################################## +# AWS Cloud Formation Stack name # +################################## +# NOTE: Defaults to "mystack" if left empty +aws_stack_name: mystack + +#################### +# AWS SAM Template # +#################### +# NOTE: This is the AWS SAM template.yml file that we need to deploy +# Pathing is from root of repository: +# Example: +# if file is called `template.yml` and is in the root of repository +# under the '.github' folder: +# sam_template: .github/template.yml +sam_template: sam-template.yml + +################################ +# region for connection to AWS # +################################ +# Default region is: us-west-2 +# if not provided below +region: ca-central-1 diff --git a/sam-template.yml b/sam-template.yml new file mode 100644 index 0000000..06ed612 --- /dev/null +++ b/sam-template.yml @@ -0,0 +1,49 @@ +Transform: 'AWS::Serverless-2016-10-31' +Resources: + + MainFunction: + # This resource creates a Lambda function. + Type: 'AWS::Serverless::Function' + + Properties: + + # This function uses the Nodejs v12 runtime. + Runtime: nodejs12.x + + # This is the Lambda function's handler. + Handler: handler.lambdaHandler + + # The location of the Lambda function code. + CodeUri: . + + # Event sources to attach to this function. In this case, we are attaching + # one API Gateway endpoint to the Lambda function. The function is + # called when a HTTP request is made to the API Gateway endpoint. + Events: + + MainPage: + # Define an API Gateway endpoint that responds to HTTP GET at /thumbnail + Type: Api + Properties: + Path: / + Method: GET + CSSFile: + # Define an API Gateway endpoint that responds to HTTP GET at /thumbnail + Type: Api + Properties: + Path: /public/index.css + Method: GET + JSFile: + # Define an API Gateway endpoint that responds to HTTP GET at /thumbnail + Type: Api + Properties: + Path: /public/main.js + Method: GET + +Outputs: + # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function + # Find out more about other implicit resources you can reference within SAM + # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api + StagingUrl: + Description: "Staging URL" + Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/" \ No newline at end of file