

# Data protection in Amazon CodeBuild
Data protection

The Amazon [shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/) applies to data protection in Amazon CodeBuild. As described in this model, Amazon is responsible for protecting the global infrastructure that runs all of the Amazon Web Services Cloud. You are responsible for maintaining control over your content that is hosted on this infrastructure. You are also responsible for the security configuration and management tasks for the Amazon Web Services services that you use. For more information about data privacy, see the [Data Privacy FAQ](https://www.amazonaws.cn/compliance/data-privacy-faq/).

For data protection purposes, we recommend that you protect Amazon Web Services account credentials and set up individual users with Amazon IAM Identity Center or Amazon Identity and Access Management (IAM). That way, each user is given only the permissions necessary to fulfill their job duties. We also recommend that you secure your data in the following ways:
+ Use multi-factor authentication (MFA) with each account.
+ Use SSL/TLS to communicate with Amazon resources. We require TLS 1.2 and recommend TLS 1.3.
+ Set up API and user activity logging with Amazon CloudTrail. For information about using CloudTrail trails to capture Amazon activities, see [Working with CloudTrail trails](https://docs.amazonaws.cn/awscloudtrail/latest/userguide/cloudtrail-trails.html) in the *Amazon CloudTrail User Guide*.
+ Use Amazon encryption solutions, along with all default security controls within Amazon Web Services services.
+ Use advanced managed security services such as Amazon Macie, which assists in discovering and securing sensitive data that is stored in Amazon S3.
+ If you require FIPS 140-3 validated cryptographic modules when accessing Amazon through a command line interface or an API, use a FIPS endpoint. For more information about the available FIPS endpoints, see [Federal Information Processing Standard (FIPS) 140-3](https://www.amazonaws.cn/compliance/fips/).

We strongly recommend that you never put confidential or sensitive information, such as your customers' email addresses, into tags or free-form text fields such as a **Name** field. This includes when you work with CodeBuild or other Amazon Web Services services using the console, API, Amazon CLI, or Amazon SDKs. Any data that you enter into tags or free-form text fields used for names may be used for billing or diagnostic logs. If you provide a URL to an external server, we strongly recommend that you do not include credentials information in the URL to validate your request to that server.

 To protect sensitive information, the following are hidden in CodeBuild logs: 
+  Strings specified using the Parameter Store in CodeBuild project environment variables or the buildspec `env/parameter-store` section. For more information, see [Systems Manager Parameter Store](https://docs.amazonaws.cn/systems-manager/latest/userguide/systems-manager-paramstore.html) and [Systems Manager Parameter Store console walkthrough](https://docs.amazonaws.cn/systems-manager/latest/userguide/sysman-paramstore-walk.html#sysman-paramstore-console) in the *Amazon EC2 Systems Manager User Guide*. 
+  Strings specified using Amazon Secrets Manager in CodeBuild project environment variables or the buildspec `env/secrets-manager` section. For more information, see [Key management](security-key-management.md). 

For more information about data protection, see the [Amazon shared responsibility model and GDPR](https://amazonaws-china.com/blogs/security/the-aws-shared-responsibility-model-and-gdpr/) blog post on the *Amazon Security Blog*.

**Topics**
+ [

# Data encryption
](security-encryption.md)
+ [

# Key management
](security-key-management.md)
+ [

# Traffic privacy
](security-traffic-privacy.md)

# Data encryption


Encryption is an important part of CodeBuild security. Some encryption, such as for data in-transit, is provided by default and does not require you to do anything. Other encryption, such as for data at-rest, you can configure when you create your project or build. 
+ **Encryption of data at-rest** - Build artifacts, such as a cache, logs, exported raw test report data files, and build results, are encrypted by default using Amazon managed keys. If you do not want to use these KMS keys, you must create and configure a customer managed key. For more information [Creating KMS Keys](https://docs.amazonaws.cn/kms/latest/developerguide/create-keys.html) and [Amazon Key Management Service concepts](https://docs.amazonaws.cn/kms/latest/developerguide/concepts.html) in the *Amazon Key Management Service User Guide*. 
  + You can store the identifier of the Amazon KMS key that CodeBuild uses to encrypt the build output artifact in the `CODEBUILD_KMS_KEY_ID` environment variable. For more information, see [Environment variables in build environments](build-env-ref-env-vars.md) 
  + You can specify a customer managed key when you create a build project. For more information, see [Set the Encryption Key Using the Console](create-project.md#encryptionkey-console) and [Set the encryption key using the CLI](create-project.md#cli.encryptionkey). 

  The Amazon Elastic Block Store volumes of your build fleet are encrypted by default using Amazon managed keys. 
+ **Encryption of data in-transit** - All communication between customers and CodeBuild and between CodeBuild and its downstream dependencies is protected using TLS connections that are signed using the Signature Version 4 signing process. All CodeBuild endpoints use SHA-256 certificates that are managed by Amazon Private Certificate Authority. For more information, see [Signature Version 4 signing process](https://docs.amazonaws.cn/general/latest/gr/signature-version-4.html) and [What is ACM PCA](https://docs.amazonaws.cn/privateca/latest/userguide/). 
+ **Build artifact encryption** - The CodeBuild service role associated with the build project requires access to a KMS key in order to encrypt its build output artifacts. By default, CodeBuild uses an Amazon managed key for Amazon S3 in your Amazon account. If you do not want to use this Amazon managed key, you must create and configure a customer managed key. For more information, see [Encrypt build outputs](setting-up-kms.md) and [Creating keys](https://docs.amazonaws.cn/kms/latest/developerguide/create-keys.html) in the *Amazon KMS Developer Guide*.

# Key management


You can protect your content from unauthorized use through encryption. Store your encryption keys in Amazon Secrets Manager, and then give the CodeBuild service role associated with the build project permission to obtain the encryption keys from your Secrets Manager account. For more information, see [Encrypt build outputs using a customer managed key](setting-up-kms.md), [Create a build project in Amazon CodeBuild](create-project.md), [Run Amazon CodeBuild builds manually](run-build.md), and [Tutorial: Storing and retrieving a secret](https://docs.amazonaws.cn/secretsmanager/latest/userguide/tutorials_basic.html). 

Use the `CODEBUILD_KMS_KEY_ID` environment variable in a build command to obtain the Amazon KMS key identifier. For more information, see [Environment variables in build environments](build-env-ref-env-vars.md). 

You can use Secrets Manager to protect credentials to a private registry that stores a Docker image used for your runtime environment. For more information, see [Private registry with Amazon Secrets Manager sample for CodeBuild](sample-private-registry.md). 

# Traffic privacy


You can improve the security of your builds by configuring CodeBuild to use an interface VPC endpoint. To do this, you do not need an internet gateway, NAT device, or virtual private gateway. It also is not required to configure PrivateLink, though it is recommended. For more information, see [Use VPC endpoints](use-vpc-endpoints-with-codebuild.md). For more information about PrivateLink and VPC endpoints, see [Amazon PrivateLink](http://www.amazonaws.cn/privatelink/) and [Accessing Amazon services through PrivateLink](https://docs.amazonaws.cn/vpc/latest/userguide/VPC_Introduction.html#what-is-privatelink). 