LoginSignup
3
1

More than 1 year has passed since last update.

TerraformでCodepipelineの検出オプションを変更する

Posted at

TerraformでCodePipelineを構築していて、ソースステージの「ソースコードの変更時にパイプラインを開始する」を「無効」にする方法がわからなかったので調べた結果を書きます

detect_changes.png

結論

  • DetectChanges = "false" でできました

確認までの流れ

  • 公式サイトのCodepipelineの定義を見るが明記されていない
  • さらにAWSのCodePipeline pipeline structure referenceの定義を確認
  • PollForSourceChangesというキーワードがあるが、これを指定してもterraformで存在しないエラーとなる
  • AWSマネジメントコンソールでCodePipelineを適当に作り、terraformerで設定値を確認して、DetectChanges = "false"があることを確認

terraformerで設定値確認

  • terraformerで確認すると存在した
terraformer
terraformer import aws --resources=codepipeline  --regions=ap-northeast-1 --profile=default
generated/aws/codepipeline/codepipeline.tf
  stage {
    action {
      category = "Source"

      configuration = {
        BranchName           = "mybranchname"
        ConnectionArn        = "arn:aws:codestar-connections:ap-northeast-1:xxxxxxxxxxxx:connection/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        DetectChanges        = "false"
        FullRepositoryId     = "owner/reponame"
        OutputArtifactFormat = "CODE_ZIP"
      }

メモ

  • DetectChangeを省略した時の.tfstateには、DetectChangesはなかった
terraform state pull
$ terraform state pull > ./terraform.tfstate.current
terraform.tfstate.current
"stage": [
    {
    "action": [
        {
        "category": "Source",
        "configuration": {
            "BranchName": "mybranchname",
            "ConnectionArn": "arn:aws:codestar-connections:ap-northeast-1:xxxxxxxxxxxx:connection/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "FullRepositoryId": "owner/reponame",
            "OutputArtifactFormat": "CODE_ZIP"
        },
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1