- 
      
 - 
        
Save wenindoubt/01eab86bd9009137e4310fde9e540690 to your computer and use it in GitHub Desktop.  
    Lamba create.ts with intrinsic service
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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) => { | |
| // ... | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment