Skip to content

Instantly share code, notes, and snippets.

@fredericbarthelet
Last active June 30, 2021 19:27
Show Gist options
  • Select an option

  • Save fredericbarthelet/b0ce38a46a3977ee880a65836ce83ed3 to your computer and use it in GitHub Desktop.

Select an option

Save fredericbarthelet/b0ce38a46a3977ee880a65836ce83ed3 to your computer and use it in GitHub Desktop.

Revisions

  1. fredericbarthelet revised this gist Oct 14, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion create.ts
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    import path from 'path';
    import { DynamoDB } from 'aws-sdk';

    import { ref } from './intrinsic';
  2. fredericbarthelet created this gist Oct 11, 2020.
    21 changes: 21 additions & 0 deletions create.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import path from 'path';
    import { DynamoDB } from 'aws-sdk';

    import { ref } from './intrinsic';
    import cloudformationResources, { MyTable } from './resources';

    export default {
    handler:'create.main',
    environment: {
    TABLE_NAME: ref(cloudformationResources, MyTable)
    },
    events: [
    { httpApi: 'POST /new'}
    ]
    }

    const DocumentClient = new DynamoDB.DocumentClient();

    const main = async (event) => {
    // ...
    }
    19 changes: 19 additions & 0 deletions resources.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    export const MyTable = {
    Type: 'AWS::DynamoDB::Table',
    Properties: {
    AttributeDefinitions: [
    { AttributeName: 'PK', AttributeType: 'S' },
    { AttributeName: 'SK', AttributeType: 'S' }
    ],
    KeySchema: [
    { AttributeName: 'PK', KeyType: 'HASH' },
    { AttributeName: 'SK', KeyType: 'RANGE' }
    ],
    BillingMode: 'PAY_PER_REQUEST'
    }
    }

    export const OtherTable = {/...};
    export const OtherResource = {/...};

    export default { MyTable, OtherTable, OtherResource };