> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/autify-university/integrations/aws-codebuild-integration.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# AWS CodeBuild 連携

Autify ではAWS CodeBuild project から簡単にテストプランやシナリオを実行できる公式の手法を提供しています。

## はじめてみよう

このドキュメントでは、皆さんのCodeBuild project でどのようにAWS CodeBuild 連携を利用するかを順に説明していきます。

### 前提条件

まず、すでにCodeBuild project を使ってステージングやプロダクション等へのソフトウェアのデプロイを行なっているものとします。そのデプロイcommand のすぐ後にAutify のテストを実行するcommand を追加することで、新しくデプロイされたソフトウェアがエンドツーエンドのユーザ体験を損ねていないことを確認できるようにします。

次に、[Autify NoCode Web](https://app.autify.com) でテストプランかテストシナリオを作成する必要があります。テストシナリオは、そのCodeBuild project でソフトウェアがデプロイされるウェブサイトに対してレコーディングすることになります。テストプランまたはシナリオのURL (例: `https://app.autify.com/projects/00/scenarios/000`) をメモしておいてください、後ほど利用します。

さらに、[パーソナルアクセストークンを生成する](https://help.autify.com/nocode-web/autify-university/integrations/integrate-with-api.md#issue-a-personal-access-token)必要があります。後ほどAWS Systems Manager Parameter Store かAWS Secrets Manager に保存するために、生成されたトークンはどこかにメモしておいて下さい。

*注: パーソナルアクセストークンは1人のユーザに紐づいてしまうので、CI/CD 連携のために組織にマシンユーザを作って、そのパーソナルアクセストークンを使うことをお勧めします。*

### パーソナルアクセストークンをAWS Systems Manager Parameter Store かAWS Secrets Manager に保存

上で生成したパーソナルアクセストークンをAWS の同じリージョン にあるAWS Systems Manager Parameter Store かAWS Secrets Manager に保存します。

Parameter Store については、CodeBuild コンソール、Parameter Store コンソール等から新しいparameter を作成できます。Parameter の名前は任意ですが、ここでは`/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN` としたと仮定します。安全に保存するために`SecureString` タイプにして下さい。[AWS による説明](https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/parameter-create-console.html)も参考にして下さい。

Secrets Manager については、Secret Manager コンソール等から新しいsecret を作成できます。Secret の名前は任意ですが、ここでは`/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN` としたと仮定します。`Plaintext` タイプを使います。[AWS による説明](https://docs.aws.amazon.com/ja_jp/secretsmanager/latest/userguide/hardcoded.html)も参考にして下さい。

**この値は絶対に`buildspec.yml` に直接保存してはいけません。平文で読むことが可能になってしまいます。**

### Autify NoCode Web を実行するCodeBuild commands を追加

それでは、お手持ちのCodeBuild project か新しいproject に新しいcommand を追加しましょう。お手持ちの`buildspec.yml` を開き、以下の例を参考にして編集してください。URL の値(`https://app.autify.com/projects/00/scenarios/000`)は上でメモしたURL になります。

{% hint style="warning" %}
ここではLinux 環境イメージを利用していると想定しています。`aws/codebuild/amazonlinux2-aarch64-*` が最も安いので一番良いと思います。
{% endhint %}

{% hint style="info" %}
環境変数はコンソールの"編集" > "環境" > "追加設定" または`UpdateProject` API でも設定することができます。
{% endhint %}

***

シンプルにテストを開始してstep を終了 (テストの完了は待たない):

```yaml
phases:
  install:
    commands:
      - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  build:
    commands:
      - autify web test run https://app.autify.com/projects/00/scenarios/000
env:
  parameter-store:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
  # OR
  secrets-manager:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
```

テストを開始して、それが完了するかタイムアウトするまで待つ:

```yaml
phases:
  install:
    commands:
      - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  build:
    commands:
      - autify web test run https://app.autify.com/projects/00/scenarios/000 --wait --timeout 300
env:
  parameter-store:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
  # OR
  secrets-manager:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
```

**警告: この設定はテスト完了を待っている間もCodeBuild build minites を消費します。タイムアウトを延長するときは注意してください。**

`--url-replacements` を使ってテストプラン又はシナリオを別のURL に対して開始する:

```yaml
phases:
  install:
    commands:
      - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  build:
    commands:
      - autify web test run https://app.autify.com/projects/00/scenarios/000 --url-replacements http://example.com=http://example.net
env:
  parameter-store:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
  # OR
  secrets-manager:
    AUTIFY_WEB_ACCESS_TOKEN: "/CodeBuild/AUTIFY_WEB_ACCESS_TOKEN"
```

`--url-replacements` はステージングのウェブサイトに対してプロダクションのウェブサイトで記録したテストシナリオを実行したい時などに有効です。

## まとめ

Autify のAWS CodeBuild 連携を使うことで、デプロイ後にテストプランやシナリオの実行を自動化できるので、無駄な時間を使うことなくリグレッションをすぐに検知して適切な行動を取ることができるようになります。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/autify-university/integrations/aws-codebuild-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
