{"id":459148,"date":"2025-05-10T21:00:52","date_gmt":"2025-05-10T21:00:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459148"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459148","title":{"rendered":"<span>\u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OIDC \u0441 GitHub Actions?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a AWS \u0438\u0437 GitHub Actions \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f. \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u0438 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u0421 OIDC GitHub Actions \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f workflow, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c.<\/p>\n<hr\/>\n<h3>\ud83d\udee0\ufe0f \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OIDC \u0432 AWS \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform<\/h3>\n<h4>1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 TLS-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 GitHub<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 OIDC \u0432 AWS \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a TLS-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 GitHub:<\/p>\n<pre><code>data \"tls_certificate\" \"github\" {   url = \"https:\/\/token.actions.githubusercontent.com\/.well-known\/openid-configuration\" } <\/code><\/pre>\n<h4>2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 OIDC-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0432 AWS<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code>resource \"aws_iam_openid_connect_provider\" \"github\" {   url             = \"https:\/\/token.actions.githubusercontent.com\"   client_id_list  = [\"sts.amazonaws.com\"]   thumbprint_list = [data.tls_certificate.github.certificates[0].sha1_fingerprint] } <\/code><\/pre>\n<h4>3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 IAM \u0440\u043e\u043b\u0438 \u0441 \u0434\u043e\u0432\u0435\u0440\u0438\u0435\u043c \u043a GitHub<\/h4>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u044f, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0443\u044e GitHub Actions \u0438\u0437 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0432\u0435\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u043e\u043b\u044c:<\/p>\n<pre><code>data \"aws_iam_policy_document\" \"github_oidc_assume_role\" {   statement {     actions = [\"sts:AssumeRoleWithWebIdentity\"]     principals {       type        = \"Federated\"       identifiers = [aws_iam_openid_connect_provider.github.arn]     }     condition {       test     = \"StringLike\"       variable = \"token.actions.githubusercontent.com:sub\"       values   = [         \"repo:&lt;your-org&gt;\/&lt;your-repo&gt;:pull_request\",         \"repo:&lt;your-org&gt;\/&lt;your-repo&gt;:ref:refs\/heads\/main\"       ]     }   } } <\/code><\/pre>\n<blockquote>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>&lt;your-org&gt;<\/code> \u0438 <code>&lt;your-repo&gt;<\/code> \u043d\u0430 \u0432\u0430\u0448\u0438, \u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u043e\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c (condition). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 PR \u0438\u043b\u0438 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u043c \u0441\u043b\u0438\u044f\u043d\u0438\u0438 \u0432 \u0432\u0435\u0442\u043a\u0443 main. \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0433 \u0438\u043b\u0438 \u0440\u0435\u043b\u0438\u0437, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e <code>ref:refs\/tags\/*<\/code>.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0440\u043e\u043b\u044c \u0441 \u044d\u0442\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u043e\u0439:<\/p>\n<pre><code>resource \"aws_iam_role\" \"github_actions\" {   name               = \"github-actions-role\"   assume_role_policy = data.aws_iam_policy_document.github_oidc_assume_role.json }  output \"role_arn\" {   value = aws_iam_role.github_actions.arn } <\/code><\/pre>\n<h4>4. \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c GitHub Actions \u0434\u043e\u0441\u0442\u0443\u043f \u043a Amazon ECR:<\/p>\n<pre><code>resource \"aws_iam_role_policy_attachment\" \"ecr_access\" {   role       = aws_iam_role.github_actions.name   policy_arn = \"arn:aws:iam::aws:policy\/AmazonEC2ContainerRegistryReadOnly\" } <\/code><\/pre>\n<hr\/>\n<h3>\u2699\ufe0f \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GitHub Actions<\/h3>\n<p>\u0412 \u0432\u0430\u0448\u0435\u043c <code>.github\/workflows\/deploy.yml<\/code> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"yaml\">permissions:   id-token: write   contents: read  on:   pull_request:   push:     branches:       - main  jobs:   deploy:     runs-on: ubuntu-latest     steps:       - name: Checkout code         uses: actions\/checkout@v4        - name: Configure AWS credentials         uses: aws-actions\/configure-aws-credentials@v4         with:           role-to-assume: arn:aws:iam::123456789012:role\/github-actions-role           aws-region: eu-central-1        - name: Describe ECR         run: aws ecr describe-repositories <\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>arn:aws:iam::123456789012:role\/github-actions-role<\/code> \u043d\u0430 ARN \u0432\u0430\u0448\u0435\u0439 IAM \u0440\u043e\u043b\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/aws-actions\/configure-aws-credentials\" rel=\"noopener noreferrer nofollow\">\u0427\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e aws-actions\/configure-aws-credentials<\/a><\/p>\n<hr\/>\n<h3>\u2705 \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 workflow \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c AWS. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c ARN \u0440\u043e\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 workflow<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0443 \u0440\u043e\u043b\u0438<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908282\/\"> https:\/\/habr.com\/ru\/articles\/908282\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a AWS \u0438\u0437 GitHub Actions \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f. \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u0438 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u0421 OIDC GitHub Actions \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f workflow, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c.<\/p>\n<hr\/>\n<h3>\ud83d\udee0\ufe0f \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OIDC \u0432 AWS \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform<\/h3>\n<h4>1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 TLS-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 GitHub<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 OIDC \u0432 AWS \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a TLS-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 GitHub:<\/p>\n<pre><code>data \"tls_certificate\" \"github\" {   url = \"https:\/\/token.actions.githubusercontent.com\/.well-known\/openid-configuration\" } <\/code><\/pre>\n<h4>2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 OIDC-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0432 AWS<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code>resource \"aws_iam_openid_connect_provider\" \"github\" {   url             = \"https:\/\/token.actions.githubusercontent.com\"   client_id_list  = [\"sts.amazonaws.com\"]   thumbprint_list = [data.tls_certificate.github.certificates[0].sha1_fingerprint] } <\/code><\/pre>\n<h4>3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 IAM \u0440\u043e\u043b\u0438 \u0441 \u0434\u043e\u0432\u0435\u0440\u0438\u0435\u043c \u043a GitHub<\/h4>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u044f, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0443\u044e GitHub Actions \u0438\u0437 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0432\u0435\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u043e\u043b\u044c:<\/p>\n<pre><code>data \"aws_iam_policy_document\" \"github_oidc_assume_role\" {   statement {     actions = [\"sts:AssumeRoleWithWebIdentity\"]     principals {       type        = \"Federated\"       identifiers = [aws_iam_openid_connect_provider.github.arn]     }     condition {       test     = \"StringLike\"       variable = \"token.actions.githubusercontent.com:sub\"       values   = [         \"repo:&lt;your-org&gt;\/&lt;your-repo&gt;:pull_request\",         \"repo:&lt;your-org&gt;\/&lt;your-repo&gt;:ref:refs\/heads\/main\"       ]     }   } } <\/code><\/pre>\n<blockquote>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>&lt;your-org&gt;<\/code> \u0438 <code>&lt;your-repo&gt;<\/code> \u043d\u0430 \u0432\u0430\u0448\u0438, \u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u043e\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c (condition). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 PR \u0438\u043b\u0438 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u043c \u0441\u043b\u0438\u044f\u043d\u0438\u0438 \u0432 \u0432\u0435\u0442\u043a\u0443 main. \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0433 \u0438\u043b\u0438 \u0440\u0435\u043b\u0438\u0437, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e <code>ref:refs\/tags\/*<\/code>.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0440\u043e\u043b\u044c \u0441 \u044d\u0442\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u043e\u0439:<\/p>\n<pre><code>resource \"aws_iam_role\" \"github_actions\" {   name               = \"github-actions-role\"   assume_role_policy = data.aws_iam_policy_document.github_oidc_assume_role.json }  output \"role_arn\" {   value = aws_iam_role.github_actions.arn } <\/code><\/pre>\n<h4>4. \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c GitHub Actions \u0434\u043e\u0441\u0442\u0443\u043f \u043a Amazon ECR:<\/p>\n<pre><code>resource \"aws_iam_role_policy_attachment\" \"ecr_access\" {   role       = aws_iam_role.github_actions.name   policy_arn = \"arn:aws:iam::aws:policy\/AmazonEC2ContainerRegistryReadOnly\" } <\/code><\/pre>\n<hr\/>\n<h3>\u2699\ufe0f \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GitHub Actions<\/h3>\n<p>\u0412 \u0432\u0430\u0448\u0435\u043c <code>.github\/workflows\/deploy.yml<\/code> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"yaml\">permissions:   id-token: write   contents: read  on:   pull_request:   push:     branches:       - main  jobs:   deploy:     runs-on: ubuntu-latest     steps:       - name: Checkout code         uses: actions\/checkout@v4        - name: Configure AWS credentials         uses: aws-actions\/configure-aws-credentials@v4         with:           role-to-assume: arn:aws:iam::123456789012:role\/github-actions-role           aws-region: eu-central-1        - name: Describe ECR         run: aws ecr describe-repositories <\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>arn:aws:iam::123456789012:role\/github-actions-role<\/code> \u043d\u0430 ARN \u0432\u0430\u0448\u0435\u0439 IAM \u0440\u043e\u043b\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/aws-actions\/configure-aws-credentials\" rel=\"noopener noreferrer nofollow\">\u0427\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e aws-actions\/configure-aws-credentials<\/a><\/p>\n<hr\/>\n<h3>\u2705 \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 workflow \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c AWS. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c ARN \u0440\u043e\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 workflow<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0443 \u0440\u043e\u043b\u0438<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908282\/\"> https:\/\/habr.com\/ru\/articles\/908282\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-459148","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459148"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459148\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}