Created
March 6, 2025 15:34
-
-
Save RWaltersMA/d75d9eb02264829c1392dbdf7f238bad to your computer and use it in GitHub Desktop.
AWS Lambda function "product-price" for use in "Orchestrating AWS Lambda and DynamoDB Resources with Apollo Connectors" article
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 handler = async (event) => { | |
const id = event.product_id; | |
const products = [ | |
{ | |
id: "RANQi6AZkUXCbZ", | |
price: { | |
default_price: 49900, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
}, | |
}, | |
{ | |
id: "RANYrWRy876AA5", | |
price: { | |
default_price: 35000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "RANb0l4hEX1P5h", | |
price: { | |
default_price: 25000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "R8Thrlp7oTghTr", | |
price: { | |
default_price: 25000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "RANfaXNYj1y69D", | |
price: { | |
default_price: 35000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "RANhWQ2gr4Nddk", | |
price: { | |
default_price: 25000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "RANj7kJZbpaST9", | |
price: { | |
default_price: 30000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
}, | |
{ | |
id: "RANlyfWstQOkdx", | |
price: { | |
default_price: 50000, | |
is_active: true, | |
currency: "usd", | |
billing_schema: "per_unit", | |
recurring: { | |
interval: 0, | |
interval_count: 3, | |
}, | |
} | |
} | |
]; | |
const product = products.find((p) => p.id == id); | |
const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); | |
await sleep(100); | |
return product?.price; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment