From 7520a16fbcbd6071aab37b5666e4e19f4f7e3b58 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Mon, 21 Oct 2024 19:06:27 -0400 Subject: [PATCH] This should fix the build We'll handle the TS transpiling ourself and point sam's esbuild at the compiled JS. --- .github/workflows/main.yml | 18 +++++------------- package.json | 4 +++- template.yaml | 16 +++++++++++----- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 802ac78..972967d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,24 +43,16 @@ jobs: # TODO: Need to run tests when we have them + - name: Compile Typescript + run: yarn run build + - name: Build artifact run: yarn run sam:build - # TODO: SAM uses esbuild and installs dependencies using npm.. Should configure oput how - # to both tools. - - name: Package & Upload SAM artifact - id: upload-sam-template - shell: bash - run: | - yarn run sam:package \ - --template template.yaml \ - --s3-bucket aws-sam-cli-sourcebucket-346402060170-us-east-1 \ - --s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \ - --region us-east-1 \ - --output-template-file packaged-template.yaml - - name: Store Artifacts uses: ServerlessOpsIO/gha-store-artifacts@v1 + with: + use_aws_sam: true deploy: needs: diff --git a/package.json b/package.json index afa6432..cf620af 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "serverlessops-catalog-api", "version": "0.0.1", "description": "ServerlessOps Catalog API for Backstage", + "type": "module", "repository": { "type": "git", "url": "git@github.com:ServerlessOpsIO/serverlessops-catalog-api.git" @@ -25,7 +26,8 @@ "test": "npm run compile && npm run unit", "test:unit": "jest", "sam:build": "sam build --parallel", - "sam:package": "sam package" + "sam:package": "sam package", + "sam:deploy": "sam deploy" }, "devDependencies": { "@backstage/catalog-model": "^1.7.0", diff --git a/template.yaml b/template.yaml index 26ddf33..98f7251 100644 --- a/template.yaml +++ b/template.yaml @@ -34,7 +34,7 @@ Parameters: EnableSourceMaps: Type: String Description: Enable source maps for debugging - Default: false + Default: 'false' Globals: @@ -69,7 +69,8 @@ Resources: CreateEntityFunction: Type: AWS::Serverless::Function Properties: - Handler: src/handlers/CreateEntity/function.handler + CodeUri: ./dist/handlers/CreateEntity + Handler: function.handler Policies: - DynamoDBCrudPolicy: TableName: !Ref DdbTable @@ -79,8 +80,10 @@ Resources: Minify: true Target: "es2020" Sourcemap: !Ref EnableSourceMaps + OutExtension: + - .js=.mjs EntryPoints: - - src/handlers/CreateEntity/function.ts + - function.js CreateEntityFunctionInvokePermission: Type: AWS::Lambda::Permission @@ -93,7 +96,8 @@ Resources: GetEntityFunction: Type: AWS::Serverless::Function Properties: - Handler: src/handlers/GetEntity/function.handler + CodeUri: ./dist/handlers/GetEntity + Handler: function.handler Policies: - DynamoDBCrudPolicy: TableName: !Ref DdbTable @@ -103,8 +107,10 @@ Resources: Minify: true Target: "es2020" Sourcemap: !Ref EnableSourceMaps + OutExtension: + - .js=.mjs EntryPoints: - - src/handlers/GetEntity/function.ts + - function.js GetEntityFunctionInvokePermission: Type: AWS::Lambda::Permission