11package software .amazon .codeartifact .repository ;
22
33import java .util .Set ;
4+ import java .util .concurrent .TimeUnit ;
45import software .amazon .awssdk .awscore .AwsResponse ;
56import software .amazon .awssdk .awscore .exception .AwsServiceException ;
67import software .amazon .awssdk .services .codeartifact .CodeartifactClient ;
78import software .amazon .awssdk .services .codeartifact .model .ResourceNotFoundException ;
9+ import software .amazon .cloudformation .exceptions .CfnGeneralServiceException ;
810import software .amazon .cloudformation .exceptions .CfnInvalidRequestException ;
911import software .amazon .cloudformation .proxy .AmazonWebServicesClientProxy ;
1012import software .amazon .cloudformation .proxy .Logger ;
1416
1517
1618public class CreateHandler extends BaseHandlerStd {
19+ private static final int PROPAGATION_DELAY_S = 10 ;
20+ private static final long PROPAGATION_DELAY_MS = TimeUnit .SECONDS .toMillis (PROPAGATION_DELAY_S );
1721 private Logger logger ;
1822
1923 protected ProgressEvent <ResourceModel , CallbackContext > handleRequest (
@@ -67,6 +71,10 @@ private ProgressEvent<ResourceModel, CallbackContext> createRepository(
6771 AwsResponse awsResponse = null ;
6872 try {
6973 awsResponse = client .injectCredentialsAndInvokeV2 (awsRequest , client .client ()::createRepository );
74+ logger .log (String .format ("waiting %s milliseconds for repository to become available" , PROPAGATION_DELAY_MS ));
75+ Thread .sleep (PROPAGATION_DELAY_MS );
76+ } catch (InterruptedException e ) {
77+ throw new CfnGeneralServiceException (e );
7078 } catch (final AwsServiceException e ) {
7179 String repositoryName = progress .getResourceModel ().getRepositoryName ();
7280 Translator .throwCfnException (e , Constants .CREATE_REPOSITORY , repositoryName );
@@ -89,6 +97,7 @@ private boolean isStabilized(
8997 try {
9098 proxyClient .injectCredentialsAndInvokeV2 (
9199 Translator .translateToReadRequest (model ), proxyClient .client ()::describeRepository );
100+ logger .log (String .format ("%s successfully stabilized." , ResourceModel .TYPE_NAME ));
92101 return true ;
93102 } catch (ResourceNotFoundException e ) {
94103 return false ;
0 commit comments