Skip to content

Instantly share code, notes, and snippets.

@farhadkzm
Last active September 18, 2018 03:05
Show Gist options
  • Save farhadkzm/4181fdecc8a097bd9cfdb3cefd9afc67 to your computer and use it in GitHub Desktop.
Save farhadkzm/4181fdecc8a097bd9cfdb3cefd9afc67 to your computer and use it in GitHub Desktop.
def GenerateConfig(context):
"""Generate YAML resource configuration."""
cluster_name = context.properties['CLUSTER_NAME']
cluster_zone = context.properties['CLUSTER_ZONE']
number_of_nodes = context.properties['NUM_NODES']
resources = []
resources.append({
'name': cluster_name,
'type': 'container.v1.cluster',
'properties': {
'zone': cluster_zone,
'cluster': {
'name': cluster_name,
'initialNodeCount': number_of_nodes,
'nodeConfig': {
'oauthScopes': [
'https://www.googleapis.com/auth/' + scope
for scope in [
'compute',
'devstorage.read_only',
'logging.write',
'monitoring'
]
]
}
}
}
})
outputs = []
outputs.append({
'name': 'endpoint',
'value': '$(ref.' + cluster_name + '.endpoint)'
})
return {'resources': resources, 'outputs': outputs}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment