UNPKG

@azure/arm-security

Version:
115 lines 6.58 kB
/* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import { __awaiter } from "tslib"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { SecurityCenter } from "@azure/arm-security"; import { DefaultAzureCredential } from "@azure/identity"; /** * This sample demonstrates how to Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * * @summary Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsAssumeRoleConnectorSubscription_example.json */ function awsAssumeRoleCreateACloudAccountConnectorForASubscription() { return __awaiter(this, void 0, void 0, function* () { const subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; const connectorName = "aws_dev2"; const connectorSetting = { authenticationDetails: { authenticationType: "awsAssumeRole", awsAssumeRoleArn: "arn:aws:iam::81231569658:role/AscConnector", awsExternalId: "20ff7fc3-e762-44dd-bd96-b71116dcdc23" }, hybridComputeSettings: { autoProvision: "On", proxyServer: { ip: "167.220.197.140", port: "34" }, region: "West US 2", resourceGroupName: "AwsConnectorRG", servicePrincipal: { applicationId: "ad9bcd79-be9c-45ab-abd8-80ca1654a7d1", secret: "<secret>" } } }; const credential = new DefaultAzureCredential(); const client = new SecurityCenter(credential, subscriptionId); const result = yield client.connectors.createOrUpdate(connectorName, connectorSetting); console.log(result); }); } awsAssumeRoleCreateACloudAccountConnectorForASubscription().catch(console.error); /** * This sample demonstrates how to Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * * @summary Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsCredConnectorSubscription_example.json */ function awsCredCreateACloudAccountConnectorForASubscription() { return __awaiter(this, void 0, void 0, function* () { const subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; const connectorName = "aws_dev1"; const connectorSetting = { authenticationDetails: { authenticationType: "awsCreds", awsAccessKeyId: "AKIARPZCNODDNAEQFSOE", awsSecretAccessKey: "<awsSecretAccessKey>" }, hybridComputeSettings: { autoProvision: "On", proxyServer: { ip: "167.220.197.140", port: "34" }, region: "West US 2", resourceGroupName: "AwsConnectorRG", servicePrincipal: { applicationId: "ad9bcd79-be9c-45ab-abd8-80ca1654a7d1", secret: "<secret>" } } }; const credential = new DefaultAzureCredential(); const client = new SecurityCenter(credential, subscriptionId); const result = yield client.connectors.createOrUpdate(connectorName, connectorSetting); console.log(result); }); } awsCredCreateACloudAccountConnectorForASubscription().catch(console.error); /** * This sample demonstrates how to Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * * @summary Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account organization credentials. * x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateGcpCredentialsConnectorSubscription_example.json */ function gcpCredentialsCreateACloudAccountConnectorForASubscription() { return __awaiter(this, void 0, void 0, function* () { const subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; const connectorName = "gcp_dev"; const connectorSetting = { authenticationDetails: { type: "service_account", authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs", authUri: "https://accounts.google.com/o/oauth2/auth", authenticationType: "gcpCredentials", clientEmail: "asc-135@asc-project-1234.iam.gserviceaccount.com", clientId: "105889053725632919854", clientX509CertUrl: "https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com", organizationId: "AscDemoOrg", privateKey: "", privateKeyId: "6efg587hra2568as34d22326b044cc20dc2af", projectId: "asc-project-1234", tokenUri: "https://oauth2.googleapis.com/token" }, hybridComputeSettings: { autoProvision: "Off" } }; const credential = new DefaultAzureCredential(); const client = new SecurityCenter(credential, subscriptionId); const result = yield client.connectors.createOrUpdate(connectorName, connectorSetting); console.log(result); }); } gcpCredentialsCreateACloudAccountConnectorForASubscription().catch(console.error); //# sourceMappingURL=connectorsCreateOrUpdateSample.js.map