azure-pipelines-tasks-terraform icon indicating copy to clipboard operation
azure-pipelines-tasks-terraform copied to clipboard

No terraform plans have been published for this pipeline run. The terraform cli task must run plan with publishPlanResults: string (where string represents the plan name) to view plans.

Open FernandoMiguel opened this issue 4 years ago • 13 comments

Describe the bug no plan view

To Reproduce Steps to reproduce the behavior:

          - task: TerraformCLI@0
            displayName: "terraform plan"
            inputs:
              command: plan
              environmentServiceName: "${{ parameters.AZURERMCONNECTION }}"
              commandOptions: "\
                -compact-warnings \
                -detailed-exitcode \
                -parallelism=300 \
                -out=terraform.tfplan.zip \
                "
              workingDirectory: self
              publishPlanResults: "plan"
              runAzLogin: false
            env:
              AZDO_PERSONAL_ACCESS_TOKEN: $(System.AccessToken)
2021-04-16T16:49:59.4663199Z ##[section]Starting: terraform plan
2021-04-16T16:49:59.4673141Z ==============================================================================
2021-04-16T16:49:59.4673451Z Task         : Terraform CLI
2021-04-16T16:49:59.4673714Z Description  : Execute terraform cli commands
2021-04-16T16:49:59.4673941Z Version      : 0.6.20
2021-04-16T16:49:59.4674168Z Author       : Charles Zipp
2021-04-16T16:49:59.4674376Z Help         : 
2021-04-16T16:49:59.4674640Z ==============================================================================
2021-04-16T16:49:59.9063555Z [command]/opt/hostedtoolcache/terraform/0.15.0/x64/terraform version
2021-04-16T16:49:59.9660409Z Terraform v0.15.0
2021-04-16T16:49:59.9661319Z on linux_amd64
2021-04-16T16:49:59.9662158Z + provider registry.terraform.io/microsoft/azuredevops v0.1.3
2021-04-16T16:49:59.9731234Z 
2021-04-16T16:49:59.9889385Z [command]/opt/hostedtoolcache/terraform/0.15.0/x64/terraform plan -compact-warnings -detailed-exitcode -parallelism=300 -out=terraform.tfplan.zip
XXXX
2021-04-16T16:50:03.3411889Z 
2021-04-16T16:50:03.3413711Z Terraform used the selected providers to generate the following execution
2021-04-16T16:50:03.3414473Z plan. Resource actions are indicated with the following symbols:
2021-04-16T16:50:03.3416239Z   [32m+[0m create
2021-04-16T16:50:03.3417169Z [0m
2021-04-16T16:50:03.3418681Z Terraform will perform the following actions:
2021-04-16T16:50:03.3419993Z 
2021-04-16T16:50:03.3457849Z 
2021-04-16T16:50:03.3458695Z [0m[1mPlan:[0m 2 to add, 0 to change, 0 to destroy.
2021-04-16T16:50:03.3605550Z ─────────────────────────────────────────────────────────────────────────────[0m
2021-04-16T16:50:03.3605779Z 
2021-04-16T16:50:03.3606073Z Saved the plan to: terraform.tfplan.zip
2021-04-16T16:50:03.3606246Z 
2021-04-16T16:50:03.3606602Z To perform exactly these actions, run the following command to apply:
2021-04-16T16:50:03.3607085Z     terraform apply "terraform.tfplan.zip"
2021-04-16T16:50:03.6492016Z 
2021-04-16T16:50:03.6560649Z ##[section]Finishing: terraform plan

Expected behavior to see plan view

Screenshots image

Agent Configuration

  • Hosted
2021-04-16T16:49:39.2191447Z ##[section]Starting: Initialize job
2021-04-16T16:49:39.2192957Z Agent name: 'Hosted Agent'
2021-04-16T16:49:39.2193353Z Agent machine name: 'fv-az131-6'
2021-04-16T16:49:39.2193626Z Current agent version: '2.184.2'
2021-04-16T16:49:39.2235508Z ##[group]Operating System
2021-04-16T16:49:39.2235790Z Ubuntu
2021-04-16T16:49:39.2235948Z 20.04.2
2021-04-16T16:49:39.2236113Z LTS
2021-04-16T16:49:39.2236268Z ##[endgroup]
2021-04-16T16:49:39.2236468Z ##[group]Virtual Environment
2021-04-16T16:49:39.2236685Z Environment: ubuntu-20.04
2021-04-16T16:49:39.2236897Z Version: 20210412.1
2021-04-16T16:49:39.2237218Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210412.1/images/linux/Ubuntu2004-README.md
2021-04-16T16:49:39.2237661Z Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F20210412.1
2021-04-16T16:49:39.2237935Z ##[endgroup]
2021-04-16T16:49:39.2238950Z Current image version: '20210412.1'
2021-04-16T16:49:39.2241416Z Agent running as: 'vsts'
2021-04-16T16:49:39.2301748Z Prepare build directory.
2021-04-16T16:49:39.2568132Z Set build variables.
2021-04-16T16:49:39.2602894Z Download all required tasks.
2021-04-16T16:49:39.2724819Z Downloading task: TerraformInstaller (0.6.20)
2021-04-16T16:49:41.3034668Z Downloading task: AzureCLI (2.1.0)
2021-04-16T16:49:41.5047811Z Downloading task: TerraformCLI (0.6.20)
2021-04-16T16:49:42.2830794Z Downloading task: PublishPipelineArtifact (1.2.3)
2021-04-16T16:49:42.3487071Z Checking job knob settings.
2021-04-16T16:49:42.3501975Z    Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
2021-04-16T16:49:42.3504501Z    Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
2021-04-16T16:49:42.3506442Z    Knob: TaskRestrictionsEnforcementMode = WarningOnly Source: $(agent.taskRestrictionsEnforcementMode) 
2021-04-16T16:49:42.3507198Z    Knob: EnableTaskRestrictionsTelemetry = true Source: $(agent.enableTaskRestrictionsTelemetry) 
2021-04-16T16:49:42.3507885Z Finished checking job knob settings.
2021-04-16T16:49:42.3915954Z Start tracking orphan processes.
2021-04-16T16:49:42.4123777Z ##[section]Finishing: Initialize job

Additional context Add any other context about the problem here.

FernandoMiguel avatar Apr 16 '21 17:04 FernandoMiguel

@FernandoMiguel is this perhaps the same issue from charleszipp/azure-pipelines-tasks-terraform-old#255, charleszipp/azure-pipelines-tasks-terraform-old#275? is your azure devops org under a visualstudio.com address or self-hosted?

Also can you capture the browser console to see if there are any errors when loading the tab?

charleszipp avatar Apr 16 '21 19:04 charleszipp

it's under https://dev.azure.com/ let me try some logs

FernandoMiguel avatar Apr 16 '21 20:04 FernandoMiguel

[Error] The source list for Content Security Policy directive 'script-src' contains an invalid source: ''strict-dynamic''. It will be ignored.
[Error] Unrecognized Content-Security-Policy directive 'worker-src'.

[Log] Running for project e359c49a-b89b-484a-b86a-56d8e7eca419 and build 343 (index.js, line 2)
[Error] Failed to load resource: the server responded with a status of 404 () (plan, line 0)
[Error] Unhandled Promise Rejection: Error: Failed to download plain plan: TFS.WebApi.Exception: 404: 
	generatorResume (index.js:2:671337)
	l (index.js:2:645656)
	promiseReactionJob

FernandoMiguel avatar Apr 16 '21 20:04 FernandoMiguel

here's the plan payload

Summary
URL: https://dev.azure.com/MYORG/ID/_apis/build/builds/343/XXX/attachments/terraform-plan-results/plan
Status: 404
Source: Network
Address: 2620:1ec:21::20.443
Initiator: 
Fetch.js:118


Request
:method: GET
:scheme: https
:authority: dev.azure.com
:path: /MYORG/ID/_apis/build/builds/343/XXX/XXXX/attachments/terraform-plan-results/plan
Content-Type: undefined
Accept: application/octet-stream;api-version=5.2-preview.2;excludeUrls=true;enumsAsNumbers=true;msDateFormat=true;noArrayWrap=true
Authorization: Bearer ey
Accept-Encoding: gzip, deflate, br
Accept-Language: en-gb
Host: dev.azure.com
Origin: https://charleszipp.gallerycdn.vsassets.io
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.2 Safari/605.1.15
Connection: keep-alive
Referer: https://charleszipp.gallerycdn.vsassets.io/extensions/charleszipp/azure-pipelines-tasks-terraform/0.6.20/1618523010842/views/terraform-plan/.dist/index.html
x-vss-reauthenticationaction: Suppress
x-tfs-fedauthredirect: Suppress

Response
:status: 404
Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: authorization
Content-Length: 0
Date: Fri, 16 Apr 2021 20:09:23 GMT
Expires: -1
Access-Control-Expose-Headers: ActivityId,X-TFS-Session,X-MS-ContinuationToken,X-VSS-GlobalMessage,ETag, Request-Context
X-Frame-Options: SAMEORIGIN
Access-Control-Max-Age: 3600
X-Content-Type-Options: nosniff
x-tfs-session: XXXX
p3p: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-vss-e2eid: XXXX
activityid: XXXX
x-tfs-processid: XXX
request-context: appId=cid-v1:XXX
x-vss-userdata: XXX.com
x-msedge-ref: Ref A: XXX Ref B: LON04EDGE0720 Ref C: 2021-04-16T20:09:23Z

FernandoMiguel avatar Apr 16 '21 20:04 FernandoMiguel

Just stumbled upon this myself. I also get 404 of the published plan. The strange thing is that it seems to work when I trigger the pipeline manually. Cannot say right now if it is because of the fact that, when I trigger manually, I get:

No changes. Infrastructure is up-to-date.

So, it could either be the trigger that is causing it, or the "contents" of the plan.

Zebusch avatar Apr 20 '21 16:04 Zebusch

Came across this issue recently too. It appears to relate to changes brought in with Terraform release 0.15.4, most likely relating to the new feature Noting changes made outside of Terraform. Through various tests, have identified that:

  • This issue does occur with Terraform v1.0.0 and v0.15.4, but not with TF v0.14.11 or v0.15.3
  • Does not occur when a plan contains changes to apply
  • Does occur when there are no changes to apply, regardless of whether the plan has detected changes made outside of Terraform or not

From a quick scan of the source, I'd say the problem relates to the following:

const planHasNoChangesRe = /^No changes. Infrastructure is up-to-date./

As Hashicorp appear to have changes the wording for when there are no changes from: No changes. Infrastructure is up-to-date. to: No changes. Your infrastructure matches the configuration.

modwyer42 avatar Jun 22 '21 05:06 modwyer42

I observed the same but I thought there is something other at fault. Each time I skip the stage apply because no changes has been detected the attachment gets into terraform-plan-results but the link actually doesn't work as the attachment is not uploaded. The plan can't be fetched on view and because of javascript as soon as plan can't be fetched everything on view fails and no plans are displayed. If it makes sense.

lolejar avatar Aug 11 '21 11:08 lolejar

Experiencing this issue too.

@charleszipp : Any idea when this can be fixed? Judging from the input of @modwyer42 above, it would seem only this particular regex needs to be updated to account for the new output text?

rob-zz avatar May 19 '22 11:05 rob-zz

Hi, and first of all thanks for great tool, but I have same issue.

rodchenkov avatar May 26 '22 15:05 rodchenkov

I'm also running into this

chase-miller avatar May 27 '22 16:05 chase-miller

Hands down the best TF plugin. This is the only part not working. Would be great if someone could fix it.

Dragonsong3k avatar Jul 15 '22 17:07 Dragonsong3k

@jason-johnson any idea on when this might get fixed? Thanks for taking this project over... seems to be the best on the market so far.

UPDATE: this is working, it only shows a plan when there are changes to be made. When it is a no change then nothing shows. I wish it would show regardless of change or not. Just so we could have a consistent pattern for business to review changes and go to a single location.

Or at least when there is a "no change" plan to say that vs the "error" we get saying there was no published plan.

jmyers82 avatar Aug 23 '22 13:08 jmyers82

I need to get my environment set up properly so I can test these things. Then, if it's as easy as it sounds then it should be fairly quick. So it could be within a month or less.

jason-johnson avatar Aug 25 '22 12:08 jason-johnson

There is a problem with the publish code.

Imagine I have 3 stages in my pipeline which deploys to 3 different sites. If the first plan has no changes, but the other 2 have, there won't be a plan published at all. It will just contain the message that the plan does not contain data.

When I provoke a change to the first run, then there will be a plan and a drop box to switch to the other plans.

yoogie27 avatar Apr 13 '23 11:04 yoogie27

@yoogie27 can you confirm that you use a different string in publishPanResult: for each stage?

jason-johnson avatar Apr 14 '23 09:04 jason-johnson

@yoogie27 can you confirm that you use a different string in publishPanResult: for each stage?

Yes, I can confirm I was using a different string.

yoogie27 avatar Apr 14 '23 16:04 yoogie27

Ok. We’ll try to reproduce that case as well. I think that’s a different case than this thread describes though, no?

jason-johnson avatar Apr 14 '23 16:04 jason-johnson

I believe this was fixed by #294. Please re-open if there is any new information here.

jason-johnson avatar Sep 30 '23 14:09 jason-johnson