(context)
return {'resources': resources}
Generates the configuration.
Generates the configuration.
Generates the configuration .
def GenerateConfig(context):
  """Generates the configuration."""

  deployment = context.env['deployment']
  instance_template = deployment + '-it'
  igm = deployment + '-igm'
  region = context.properties['region']
  port = context.properties['port']
  tp_name = deployment + '-tp'
  fr_name = deployment + '-fr'

  # Create a dictionary which represents the resources
  # (Intstance Template, IGM, etc.)
  resources = [
      {
          # Create the Instance Template
          'name': instance_template,
          'type': 'compute.v1.instanceTemplate',
          'properties': {
              'properties': {
                  'machineType':
                      'f1-micro',
                  'networkInterfaces': [{
                      'network':
                          URL_BASE + context.env['project'] +
                          '/global/networks/default',
                      'accessConfigs': [{
                          'name': 'External NAT',
                          'type': 'ONE_TO_ONE_NAT'
                      }]
                  }],
                  'disks': [{
                      'deviceName': 'boot',
                      'type': 'PERSISTENT',
                      'boot': True,
                      'autoDelete': True,
                      'initializeParams': {
                          'sourceImage':
                              URL_BASE +
                              'debian-cloud/global/images/family/debian-9'
                      }
                  }]
              }
          }
      },
      {
          # Instance Group Manager
          'name': igm,
          'type': 'compute.v1.regionInstanceGroupManager',
          'properties': {
              'region': region,
              'baseInstanceName': deployment + '-instance',
              'instanceTemplate': '$(ref.' + instance_template + '.selfLink)',
              'targetSize': 1,
              'autoHealingPolicies': [{
                  'initialDelaySec': 60
              }]
          }
      },
      {
          # Autoscaler
          'name': deployment + '-as',
          'type': 'compute.v1.regionAutoscaler',
          'properties': {
              'target': '$(ref.' + igm + '.selfLink)',
              'region': region,
              'autoscalingPolicy': {
                  'minNumReplicas': context.properties['minSize'],
                  'maxNumReplicas': int(context.properties['maxSize']),
                  'cpuUtilization': {
                      'utilizationTarget': 0.8
                  },
                  'coolDownPeriodSec': 90
              }
          }
      },
      {
          # Load Balancer - this is two resource: TargetPool & ForwardingRule
          'name': tp_name,
          'type': 'compute.v1.targetPool',
          'properties': {
              'region': region,
          }
      },
      {
          'name': fr_name,
          'type': 'compute.v1.forwardingRule',
          'properties': {
              'region': region,
              'portRange': port,
              'target': '$(ref.' + tp_name + '.selfLink)'
          }
      }
  ]

  return {'resources': resources}
def GenerateConfig ( context ) : deployment = context . env [ 'deployment' ] instance_template = deployment + '-it' igm = deployment + '-igm' region = context . properties [ 'region' ] port = context . properties [ 'port' ] tp_name = deployment + '-tp' fr_name = deployment + '-fr' # Create a dictionary which represents the resources # (Intstance Template, IGM, etc.) resources = [ { # Create the Instance Template 'name' : instance_template , 'type' : 'compute.v1.instanceTemplate' , 'properties' : { 'properties' : { 'machineType' : 'f1-micro' , 'networkInterfaces' : [ { 'network' : URL_BASE + context . env [ 'project' ] + '/global/networks/default' , 'accessConfigs' : [ { 'name' : 'External NAT' , 'type' : 'ONE_TO_ONE_NAT' } ] } ] , 'disks' : [ { 'deviceName' : 'boot' , 'type' : 'PERSISTENT' , 'boot' : True , 'autoDelete' : True , 'initializeParams' : { 'sourceImage' : URL_BASE + 'debian-cloud/global/images/family/debian-9' } } ] } } } , { # Instance Group Manager 'name' : igm , 'type' : 'compute.v1.regionInstanceGroupManager' , 'properties' : { 'region' : region , 'baseInstanceName' : deployment + '-instance' , 'instanceTemplate' : '$(ref.' + instance_template + '.selfLink)' , 'targetSize' : 1 , 'autoHealingPolicies' : [ { 'initialDelaySec' : 60 } ] } } , { # Autoscaler 'name' : deployment + '-as' , 'type' : 'compute.v1.regionAutoscaler' , 'properties' : { 'target' : '$(ref.' + igm + '.selfLink)' , 'region' : region , 'autoscalingPolicy' : { 'minNumReplicas' : context . properties [ 'minSize' ] , 'maxNumReplicas' : int ( context . properties [ 'maxSize' ] ) , 'cpuUtilization' : { 'utilizationTarget' : 0.8 } , 'coolDownPeriodSec' : 90 } } } , { # Load Balancer - this is two resource: TargetPool & ForwardingRule 'name' : tp_name , 'type' : 'compute.v1.targetPool' , 'properties' : { 'region' : region , } } , { 'name' : fr_name , 'type' : 'compute.v1.forwardingRule' , 'properties' : { 'region' : region , 'portRange' : port , 'target' : '$(ref.' + tp_name + '.selfLink)' } } ] return { 'resources' : resources }