( projectId = 'YOUR_PROJECT_ID', region = 'YOUR_CLUSTER_REGION', clusterName = 'YOUR_CLUSTER_NAME' )
| 21 | /*eslint no-warning-comments: [0, { "terms": ["todo", "fixme"], "location": "anywhere" }]*/ |
| 22 | |
| 23 | function main( |
| 24 | projectId = 'YOUR_PROJECT_ID', |
| 25 | region = 'YOUR_CLUSTER_REGION', |
| 26 | clusterName = 'YOUR_CLUSTER_NAME' |
| 27 | ) { |
| 28 | // [START dataproc_create_cluster] |
| 29 | const dataproc = require('@google-cloud/dataproc'); |
| 30 | |
| 31 | // TODO(developer): Uncomment and set the following variables |
| 32 | // projectId = 'YOUR_PROJECT_ID' |
| 33 | // region = 'YOUR_CLUSTER_REGION' |
| 34 | // clusterName = 'YOUR_CLUSTER_NAME' |
| 35 | |
| 36 | // Create a client with the endpoint set to the desired cluster region |
| 37 | const client = new dataproc.v1.ClusterControllerClient({ |
| 38 | apiEndpoint: `${region}-dataproc.googleapis.com`, |
| 39 | projectId: projectId, |
| 40 | }); |
| 41 | |
| 42 | async function createCluster() { |
| 43 | // Create the cluster config |
| 44 | const request = { |
| 45 | projectId: projectId, |
| 46 | region: region, |
| 47 | cluster: { |
| 48 | clusterName: clusterName, |
| 49 | config: { |
| 50 | masterConfig: { |
| 51 | numInstances: 1, |
| 52 | machineTypeUri: 'n1-standard-2', |
| 53 | }, |
| 54 | workerConfig: { |
| 55 | numInstances: 2, |
| 56 | machineTypeUri: 'n1-standard-2', |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | }; |
| 61 | |
| 62 | // Create the cluster |
| 63 | const [operation] = await client.createCluster(request); |
| 64 | const [response] = await operation.promise(); |
| 65 | |
| 66 | // Output a success message |
| 67 | console.log(`Cluster created successfully: ${response.clusterName}`); |
| 68 | // [END dataproc_create_cluster] |
| 69 | } |
| 70 | |
| 71 | createCluster(); |
| 72 | } |
| 73 | |
| 74 | main(...process.argv.slice(2)); |
no test coverage detected