Documentation forSolarWinds Observability SaaS

AWS CodeStar Integration

If you use AWS CodeStar to quickly develop, build, and deploy applications on AWS, you can send build and deployment events to SolarWinds Observability SaaS and associate events with an entity. Events from AWS CodeStar are included in SolarWinds Observability time-based charts, such as the Health Status widget. With this integration, you can correlate deployment events with the health status of an entity.

  1. Create an ingestion API token and copy the token for use in a CodeBuild pipeline action. See API Tokens.

  2. Create a pipeline in CodeBuild. See Edit a pipeline in CodePipeline in AWS Documentation.

  3. Add an AWS Lambda action to call the SolarWinds Observability Events REST API. When adding the action, do the following actions:

    • Add the swo-codestar-in-BuildArtifact input artifact.

    • Enter codestar-SWO-integration as a Function name.

    • Enter #{ApplicationSource.CommitId} in the User parameters field.

    See Adding Lambda actions.

  4. Create the following Lambda function to make an HTTP request to the SolarWinds Observability API, customizing for the AWS region (if needed) and for the following updates to the options object:

    1. hostname: 'api.xx-yy.cloud.solarwinds.com',

      Replace xx-yy with the data center your organization's data is hosted in, see Find the data center and endpoints for your organization.

    2. 'X-Otel-Resource-Attr': '<EntityTypeTagName>=<EntityIdentifier>',

      Replace <EntityTypeTagName> with the tag name for your entity type and <EntityIdentifier> with ID of the entity you want to associate with the CodeStar project.

      • The entity type tag name follows the format sw.entity.<type>.id. See Determine the entity type tag name for your entity type for a full list.

      • The entity ID follows the format e-XXXXXXXXXXXXXXXXXXX and can be found by looking at the URL in your browser when looking at your entity in the Entity Explorer. For example, the entity ID for the entity showing in the Entity Explorer for the following URL is e-1234512345123451234:

        https://my.na-01.cloud.solarwinds.com/123451234512345123/entities/websites/e-1234512345123451234/overview

    const https = require('https');
    const AWS = require('aws-sdk');
    AWS.config.update({ region: 'us-east-1' });
    const codepipeline = new AWS.CodePipeline();
    const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME;
    const encrypted = process.env['TOKEN'];
    let decrypted;
    
    exports.handler = async (event, context) => {
        console.log(JSON.stringify(event["CodePipeline.job"].data.actionConfiguration.configuration.UserParameters));
        
        const commitId = 'abcdefg';
        
        if (!decrypted) {
            // Decrypt code should run once and variables stored outside of the
            // function handler so that these are decrypted once per container
            const kms = new AWS.KMS();
            try {
                const req = {
                    CiphertextBlob: Buffer.from(encrypted, 'base64'),
                    EncryptionContext: { LambdaFunctionName: functionName },
                };
                const data = await kms.decrypt(req).promise();
                decrypted = data.Plaintext.toString('ascii');
            } catch (err) {
                console.log('Decrypt error:', err);
                throw err;
            }
        }
        
        const options = {
            hostname: 'api.xx-yy.cloud.solarwinds.com',
            port: 443,
            path: '/v1/changeevents',
            method: 'POST',
            headers: {
                Authorization: `Bearer ${decrypted}`,
                'X-Otel-Resource-Attr': '<EntityTypeTagName>=<EntityIdentifier>',
                'Content-Type': 'application/json'
            }
        }
        
        const data = {
            name: 'codestar',
            title: 'test',
            description: `commitId ${commitId} deployed`
        }
        const response = await new Promise((resolve, rej) => {
            const req = https.request(options, (res) => {
                let body = '';
                console.log('Status:', res.statusCode);
                console.log('Headers:', JSON.stringify(res.headers));
                res.setEncoding('utf8');
                res.on('data', (chunk) => body += chunk);
                res.on('end', () => {
                    console.log('Successfully processed HTTPS response');
                    // If we know it's JSON, parse it
                    if (res.headers['content-type'] === 'application/json') {
                        body = JSON.parse(body);
                    }
                    resolve(body);
                });
            });
            req.on('error', rej);
            req.write(JSON.stringify(data));
            req.end();
        });
        
        const jobId = event["CodePipeline.job"].id;
        const params = {  
            jobId: jobId  
        };
        await codepipeline.putJobSuccessResult(params).promise();  
        return response;
    };
    
  5. Add an encrypted environment variable, with TOKEN as the key and the API token as the value.

When you use the AWS CodeStar console to make a code change, commit it to the repository, and complete a build, the build event is sent to SolarWinds Observability SaaS and associated with your entity.

Determine the entity type tag name for your entity type

Use the following table to find the entity type tag name for the entity or monitored element that you want to associate with your CodeStar project.

Entity type Entity type tag name
Apache Web Server sw.entity.ApacheInstance.id
AWS API Gateway sw.entity.AwsApiGateway.id
AWS ApplicationELB sw.entity.AwsApplicationELB.id
AWS Aurora Cluster sw.entity.AwsAuroraCluster.id
AWS Aurora Instance sw.entity.AwsAuroraInstance.id
AWS Auto Scaling Group sw.entity.AwsAutoScalingGroup.id
AWS CloudFront sw.entity.AwsCloudFrontDistribution.id
AWS EBS sw.entity.AwsEBS.id
AWS EC2 sw.entity.EC2Host.id
AWS EFS sw.entity.AwsEFS.id
AWS Elastic Beanstalk sw.entity.AwsElasticBeanstalkEnvironment.id
AWS ELB sw.entity.AwsELB.id
AWS Lambda sw.entity.AwsLambda.id
AWS NAT Gateway sw.entity.AwsNatGateway.id
AWS RDS sw.entity.AwsRDS.id
AWS S3 sw.entity.AwsS3.id
AWS Transit Gateway sw.entity.AwsTransitGateway.id
AWS VPN sw.entity.AwsVPN.id
Azure App Service sw.entity.AzureAppService.id
Azure Blob Storage sw.entity.AzureBlobStorage.id
Azure Content Delivery Networks (CDN) sw.entity.AzureCdn.id
Azure Cosmos DB sw.entity.AzureCosmosDb.id
Azure Event Hubs sw.entity.AzureEventHubs.id
Azure Files sw.entity.AzureFiles.id
Azure FrontDoor sw.entity.AzureFrontDoor.id
Azure Functions sw.entity.AzureFunction.id
Azure Key Vaults sw.entity.AzureKeyVault.id
Azure Service Bus sw.entity.AzureServiceBus.id
Azure SQL Database sw.entity.AzureSqlDatabase.id
Azure Virtual Machines (VM) sw.entity.AzureVMHost.id
Azure VM Scale Sets sw.entity.AzureVirtualMachineScaleSet.id
database instance sw.entity.DatabaseInstance.id
K8s cluster sw.entity.KubernetesCluster.id
K8s DaemonSet sw.entity.KubernetesDaemonSet.id
K8s Deployment sw.entity.KubernetesDeployment.id
K8s Namespace sw.entity.KubernetesNamespace.id
K8s Node sw.entity.KubernetesNode.id
K8s Pod sw.entity.KubernetesPod.id
K8s StatefulSet sw.entity.KubernetesStatefulSet.id
network device sw.entity.NetworkDevice.id
network device interface sw.entity.NetworkInterface.id
network device volume sw.entity.DeviceVolume.id
NGINX sw.entity.NginxInstance.id
service sw.entity.Service.id
website sw.entity.Website.id