(context)
return { 'resources': resources }
Generate YAML resource configuration.
Generate YAML resource configuration.
Generate YAML resource configuration .
def GenerateConfig(context):
  """Generate YAML resource configuration."""
  deployment_name = context.env['deployment']
  instance_name = deployment_name + '-instance'
  replica_name = deployment_name + '-replica'
  database_name = deployment_name + '-db'
  failover_name = deployment_name + '-failover'

  resources = [{
      'name': instance_name,
      'type': 'gcp-types/sqladmin-v1beta4:instances',
      'properties': {
          'region': context.properties['region'],
          'settings': {
              'tier': context.properties['tier'],
              'backupConfiguration' : {
                 'binaryLogEnabled': True,
                 'enabled': True
              }
          }
      }
  }, {
      'name': database_name,
      'type': 'gcp-types/sqladmin-v1beta4:databases',
      'properties': {
          'name': database_name,
          'instance': ''.join(['$(ref.', instance_name,'.name)']),
          'charset': 'utf8'
      }
  }]
  dependency=database_name
  for n in range(0,context.properties['readReplicas']):
    name = ''.join([replica_name,'-',str(n)])
    resources.append({'name': name,
                      'type': 'gcp-types/sqladmin-v1beta4:instances',
                      'metadata': {
                         'dependsOn': [ dependency ]
                      },
                      'properties': {
                          'region': context.properties['region'],
                          'masterInstanceName': ''.join(['$(ref.', instance_name,'.name)']),
                          'settings': {
                              'tier': context.properties['tier'],
                              'replicationType': context.properties['replicationType']
                           }
                       }
                    })
    dependency=name
  if context.properties['failOver']:
    resources.append({'name': failover_name ,
                      'type': 'gcp-types/sqladmin-v1beta4:instances',
                      'metadata': {
                         'dependsOn': [ dependency ]
                      },
                      'properties': {
                          'replicaConfiguration':{'failoverTarget': True},
                          'region': context.properties['region'],
                          'masterInstanceName': ''.join(['$(ref.', instance_name,'.name)']),
                          'settings': {
                              'tier': context.properties['tier'],
                              'replicationType': context.properties['replicationType']
                           }
                       }
                    })
    dependency=failover_name
  return { 'resources': resources }
def GenerateConfig ( context ) : deployment_name = context . env [ 'deployment' ] instance_name = deployment_name + '-instance' replica_name = deployment_name + '-replica' database_name = deployment_name + '-db' failover_name = deployment_name + '-failover' resources = [ { 'name' : instance_name , 'type' : 'gcp-types/sqladmin-v1beta4:instances' , 'properties' : { 'region' : context . properties [ 'region' ] , 'settings' : { 'tier' : context . properties [ 'tier' ] , 'backupConfiguration' : { 'binaryLogEnabled' : True , 'enabled' : True } } } } , { 'name' : database_name , 'type' : 'gcp-types/sqladmin-v1beta4:databases' , 'properties' : { 'name' : database_name , 'instance' : '' . join ( [ '$(ref.' , instance_name , '.name)' ] ) , 'charset' : 'utf8' } } ] dependency = database_name for n in range ( 0 , context . properties [ 'readReplicas' ] ) : name = '' . join ( [ replica_name , '-' , str ( n ) ] ) resources . append ( { 'name' : name , 'type' : 'gcp-types/sqladmin-v1beta4:instances' , 'metadata' : { 'dependsOn' : [ dependency ] } , 'properties' : { 'region' : context . properties [ 'region' ] , 'masterInstanceName' : '' . join ( [ '$(ref.' , instance_name , '.name)' ] ) , 'settings' : { 'tier' : context . properties [ 'tier' ] , 'replicationType' : context . properties [ 'replicationType' ] } } } ) dependency = name if context . properties [ 'failOver' ] : resources . append ( { 'name' : failover_name , 'type' : 'gcp-types/sqladmin-v1beta4:instances' , 'metadata' : { 'dependsOn' : [ dependency ] } , 'properties' : { 'replicaConfiguration' : { 'failoverTarget' : True } , 'region' : context . properties [ 'region' ] , 'masterInstanceName' : '' . join ( [ '$(ref.' , instance_name , '.name)' ] ) , 'settings' : { 'tier' : context . properties [ 'tier' ] , 'replicationType' : context . properties [ 'replicationType' ] } } } ) dependency = failover_name return { 'resources' : resources }