Overview
Artifacts in CI/CD pipelines pass through several AWS services. Access to those artifacts can be controlled at multiple layers:
Cross-account access typically requires both the caller’s IAM permissions and the target resource’s resource-based policy to grant access. When KMS-encrypted artifacts are involved, the KMS key policy is an additional gate that must permit decryption or data key generation.
S3 and CodePipeline artifacts
CodePipeline stores pipeline artifacts in S3 during execution. For single-account pipelines, explicit bucket policies are sometimes optional if IAM permissions are sufficient. For cross-account pipelines you usually need a bucket policy granting access to the other account’s pipeline or build role for the specific bucket and prefix used for artifacts. Block Public Access settings block public exposure but do not replace explicit cross-account permissions — bucket policies remain the correct mechanism for granting access between accounts.
- Limit the object
Resourceto the specific prefix used for artifacts where possible (e.g.,arn:aws:s3:::example-artifacts-bucket/pipelines/*) to follow least-privilege. - If using KMS encryption on S3 objects, ensure the KMS key policy allows the pipeline/build roles to call
kms:Decrypt,kms:GenerateDataKey, etc.
CodeDeploy and service roles
If you do not see deployments, verify the relevant service role exists and that the pipeline hasiam:PassRole permission to pass a service role to CodeDeploy/CodeBuild/other services. Service roles allow these services to act on your behalf.

Creating a pipeline and selecting a service role
When creating a pipeline you can select an existing service role or let the console create one. If you use an existing role, inspect its trust policy and attached permission policies to confirm the role can perform required operations (S3, CodeBuild, CodeDeploy, CodeArtifact, etc.).
Inspecting the pipeline role
The pipeline role must:- Be assumable by CodePipeline (proper trust relationship).
- Include permissions required by pipeline stages:
- S3: read/write artifacts
- CodeBuild:
codebuild:StartBuild,codebuild:BatchGetBuilds(and related actions) - CodeDeploy:
codedeploy:*actions needed for deployment - CodeStar Connections or other services if the pipeline integrates external sources

- S3:
s3:GetObject,s3:PutObject,s3:ListBucket - CodeBuild:
codebuild:StartBuild,codebuild:BatchGetBuilds,codebuild:BatchGetProjects - CodeDeploy:
codedeploy:CreateDeployment,codedeploy:GetDeployment,codedeploy:RegisterOnPremisesInstance, etc. - CodeStar connections: actions to start interactions with external repositories if configured
Build and deploy roles (examples)
Build roles frequently require:- ECR read access (to pull base images)
- Secrets Manager or SSM Parameter Store access (for secrets/config)
- Permission to write logs and store build artifacts
Resource: "*" wherever feasible.
CodeArtifact repository policies and cross-account access
CodeArtifact supports resource-based repository policies that permit other accounts to read from or publish to a repository. You can grant different sets of actions to multiple principals in a single repository policy (for example, granting read access to build roles and publish access to a dedicated publisher role). Example CodeArtifact repository policy allowing a build role in one account to read and a publisher role in another account to publish:- Ensure the caller has the required identity policy allowing CodeArtifact actions.
- Confirm the repository policy explicitly permits the caller/principal.
- If the repository is in another account, verify the repository policy uses the correct principal ARN and actions.
KMS key policies and encrypted artifacts
If artifacts are encrypted with a customer-managed KMS key (CMK), the key policy must allow the service roles to use the key for cryptographic operations. Typical required actions includekms:Encrypt, kms:Decrypt, kms:ReEncrypt*, kms:GenerateDataKey*, and kms:DescribeKey.
Example statement in a KMS key policy allowing two service roles to use the key:
- Any IAM policies granting KMS actions to roles/users are present.
- There are no SCPs that deny KMS actions across the organization.
- The KMS key is in the same region as the encrypted artifacts or configured for cross-region usage if needed.
Troubleshooting checklist
If you encounter permission problems accessing artifacts, check these items in order:
- Identity-based IAM policy for the caller (role or user).
- Resource-based policy on the target (S3 bucket policy, CodeArtifact repository policy).
- KMS key policy (if the artifact is encrypted).
- Organization Service Control Policies (SCPs).
- Any organization-level resource control policies (RCPs).
- VPC endpoint policy (if using VPC endpoints for S3 or other services).
- Permission boundaries applied to the IAM principal.
- Enforce least-privilege: prefer narrow Resource ARNs and action lists rather than wildcards.
- When one AWS service invokes another (e.g., CodePipeline invoking CodeBuild or CodeDeploy), the invoker must be allowed to
iam:PassRolefor the service role being passed — validate thatiam:PassRoleis included in the invoker’s permissions and scoped to the correct role ARN. - Confirm trust relationships (the role’s assume-role policy) allow the correct service principal (for example,
codepipeline.amazonaws.comfor pipeline roles).
Useful links and references
- IAM Policies and Permissions
- Amazon S3 Bucket Policies
- AWS KMS Key Policy
- AWS CodeArtifact Repository Permissions
- CodePipeline Tutorial and Permissions