AWS_Developer_Tools - kamialie/knowledge_corner GitHub Wiki

Contents

X-Ray

Distributed tracing system. Helps to analyze and debug distributed applications. Provides complete view of requests, filters visual data across payloads, functions, traces, APIs, and more.

Integrates with many AWS services, such as EC2, ECS, ELB, Lambda, SNS, and so on, and can also be integrated within the applications written in Java, Node.js, Python, .NET, Go, and Ruby. Automatically captures API calls metadata made to AWS services with AWS SDK. X-Ray agent needs to be installed on EC2, and application needs to use AWS SDK in order to send trace data. For applications running in containers in ECS X-Ray agent needs to run in a separate container, either one per node or as a side car.


Service map is a visual representation of an application - various parts that communicate with each other via HTTP.

Annotations are additional data about request that can be recorded alongside it. It is a key-value pairs that are indexed that can later be filtered and searched. Metadata is similar to annotations, but are not indexed.

Segments represent information sent per application, subsegments are optional nesting for adding more details, trace is a collection of segments that form end-to-end trace.

Sampling settings

By default SDK records the first request each second (aka reservoir) and 5% (aka rate) of any additional requests. Reservoir defines number of requests per second. Both settings can be customized. Doesn't require restart of application(s). Both settings set to 1 would result in all requests being sent to X-Ray service, debug use case. Settings are located in CloudWatch settings page.


Configuring application

Enable in 2 steps:

  1. Import AWS X-Ray SDK in you code (Java, Python, Go, Node.js, .NET) - requires little modification, SDK automatically captures AWS API calls, HTTP requests, and database calls
  2. Install X-Ray daemon or enable X-Ray AWS Integration - acts as a low level UDP package interceptor; also requires IAM permissions to write to X-Ray

To enable in Lambda, ensure that:

  • IAM role contains required permission, AWSX-RayWriteOnlyAccess
  • X-Ray is imported in code
  • Lambda X-Ray Active Tracing is enabled

AWS_XRAY_DAEMON_ADDRESS is used by SDK to find a local daemon it needs to publish data to.

Required write APIs (used by daemon); needs access to write data and to read sampling settings:

  • PutTraceSegments
  • PutTelemetryRecords
  • GetSamplingRules
  • GetSamplingTargets
  • GetSamplingStatisticsSummaries

AWS Distro for OpenTelemetry

AWS supported distribution of open-source OpenTelemetry project. Provides a single set of APIs, libraries, agents and collector services. Similar to X-Ray, able to collect distributed traces and metrics from custom applications, and metadata from AWS resources and services.

CodeCommit

Managed source control service built on top of Git.

CodeBuild

Automated build service - compiles source code, runs tests and produces artifacts.

CodeDeploy

Automated deployment service. Works with EC2, on-prem instance and Lambda.

Revision is new version of application.

Deployment approaches:

Name Description
In-Place Application is stopped on each instance and new release is installed. Also called Rolling update. Capacity is reduced during update, as instances are updated one by one in-place. Doesn't support Lambda.
Blue/Green New release is installed on new instances, blue representing active deployment, green - new release. Rollback can be easily done by switching traffic routing back to old deployment. Both environment remain active until terminated by user.

AppSpec

AppSpec file is a deployment configuration file, which defines various parameters. EC2 deployment only supports YAML format, Lambda supports both JSON and YAML. Must be placed at the root of the directory.

File structure:

Field name Usage
version Reserved field, currently allows only 0.0 value.
os Operating system, e.g. Linux, Windows.
files List of files with location and destinations that need to be copied over.
hooks Lifecycle event hooks are scripts that are set to run at specific points during deployment lifecycle.

Lifecycle event hooks

Event hooks run in specific order, which is known as Run Order.

Hook list separated by 3 phases:

  1. De-register from load balancer
    1. BeforeBlockTraffic - before de-registration
    2. BlockTraffic - de-registration
    3. AfterTraffic - after being de-registered
  2. Application deployment
    1. ApplicationStop - gracefully stop the application
    2. DownloadBundle - copy revision file to temporary location
    3. BeforeInstall - run pre-installation scripts, e.g. backups, decrypting secrets
    4. Install - copy revision to final location
    5. AfterInstall - run post-installation scripts
    6. ApplicationStart - start any services that might have been stopped during ApplicationStop
    7. ValidateService - run tests
  3. Re-register to load balancer
    1. BeforeAllowTraffic - before re-registration
    2. AllowTraffic - re-registration
    3. AfterTraffic - after being re-registered

CodePipeline

Fully managed CI/CD orchestration service.

CodeArtifact

Artifact repository for storing software packages.

Integrates with public repositories such as npm registry, Python Package Index, Maven Central. In order to configure public repository create a domain (where repositories are located) in CodeArtifact, a repository, and an upstream repository, which will be used for configuring external connection. Clients connect to repository, which pulls from public repository through upstream repository that is inside same domain.