88# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
99# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1010# limitations under the License.
11-
1211#
1312# This module contains all the classes required to convert a Cluster into a CFN template by using CDK.
1413#
14+
15+ import logging
1516import os
1617import tempfile
1718
2021from pcluster .models .s3_bucket import S3Bucket
2122from pcluster .utils import load_yaml_dict
2223
24+ LOGGER = logging .getLogger (__name__ )
25+
2326
2427class CDKTemplateBuilder :
2528 """Create the template, starting from the given resources."""
@@ -29,16 +32,20 @@ def build_cluster_template(
2932 cluster_config : BaseClusterConfig , bucket : S3Bucket , stack_name : str , log_group_name : str = None
3033 ):
3134 """Build template for the given cluster and return as output in Yaml format."""
35+ LOGGER .info ("Importing CDK..." )
3236 from aws_cdk .core import App # pylint: disable=C0415
3337
3438 from pcluster .templates .cluster_stack import ClusterCdkStack # pylint: disable=C0415
3539
40+ LOGGER .info ("CDK import completed successfully" )
41+ LOGGER .info ("Starting CDK template generation..." )
3642 with tempfile .TemporaryDirectory () as tempdir :
3743 output_file = str (stack_name )
3844 app = App (outdir = str (tempdir ))
3945 ClusterCdkStack (app , output_file , stack_name , cluster_config , bucket , log_group_name )
4046 app .synth ()
4147 generated_template = load_yaml_dict (os .path .join (tempdir , f"{ output_file } .template.json" ))
48+ LOGGER .info ("CDK template generation completed successfully" )
4249
4350 return generated_template
4451
0 commit comments