File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
ab-testing/deploy-lambda/src/lib Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -19,18 +19,32 @@ export const fetchAndDeployArtifacts = async (deployments: ArtifactInfo[]) => {
1919 const CONFIG_PREFIX = `${ STAGE } /config/ab-testing` ;
2020
2121 try {
22- await Promise . all (
22+ const artifacts = await Promise . all (
2323 deployments . map ( async ( { artifact, dictionary } ) => {
2424 console . log (
2525 `Fetching artifact /${ ARTIFACT_BUCKET_NAME } ${ CONFIG_PREFIX } /${ artifact } from S3 and deploying to Fastly dictionary ${ dictionary . name } ` ,
2626 ) ;
27- const abTestGroups = await fetchDictionaryArtifact (
28- ARTIFACT_BUCKET_NAME ,
29- `${ CONFIG_PREFIX } /${ artifact } ` ,
30- ) ;
31- return await deployDictionary ( dictionary , abTestGroups ) ;
27+ return {
28+ dictionary,
29+ keyValues : await fetchDictionaryArtifact (
30+ ARTIFACT_BUCKET_NAME ,
31+ `${ CONFIG_PREFIX } /${ artifact } ` ,
32+ ) ,
33+ } ;
3234 } ) ,
3335 ) ;
36+
37+ for ( const [ i , { dictionary, keyValues } ] of artifacts . entries ( ) ) {
38+ await deployDictionary ( dictionary , keyValues ) ;
39+ console . log (
40+ `Successfully deployed artifact to Fastly dictionary ${ dictionary . name } ` ,
41+ ) ;
42+ if ( i !== artifacts . length - 1 ) {
43+ // Adding a small delay between deployments to avoid overwhelming Fastly API,
44+ // and ensure dictionaries are updated in order.
45+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
46+ }
47+ }
3448 } catch ( error ) {
3549 console . error ( "Error in fetchAndDeployArtifacts:" , error ) ;
3650 throw error ;
You can’t perform that action at this time.
0 commit comments