Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to update existing service #480

Closed
HelloFillip opened this issue Mar 22, 2024 · 4 comments
Closed

Unable to update existing service #480

HelloFillip opened this issue Mar 22, 2024 · 4 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed

Comments

@HelloFillip
Copy link

When using the Fastly APIs directly it's possible to update an existing service, previously created through the dashboard.

Currently I'm unable to achieve the same with Pulumi.

I'm running a refresh, and then up command (with the Automation API) with the following:

	result, err := fastly.NewServiceVcl(pulumiContext, "edge-network-delivery", &fastly.ServiceVclArgs{
		Activate: pulumi.Bool(false),
		Backends: &fastly.ServiceVclBackendArray{
			&fastly.ServiceVclBackendArgs{
				Address:             pulumi.String("***-some-web-address.dev***"),
				AutoLoadbalance:     pulumi.Bool(false),
				BetweenBytesTimeout: pulumi.Int(10000),
				ConnectTimeout:      pulumi.Int(1000),
				ErrorThreshold:      pulumi.Int(0),
				FirstByteTimeout:    pulumi.Int(15000),
				Name:                pulumi.String("Home Site"),
				OverrideHost:        pulumi.String("***-some-web-address.dev***"),
				Shield:              pulumi.String("hel-helsinki.fi"),
				SslCertHostname:     pulumi.String("*.custom-hostname.dev"),
			},
		},
		Domains: &fastly.ServiceVclDomainArray{
			&fastly.ServiceVclDomainArgs{
				Name: pulumi.String("my-domain.site"),
			},
		},
		Reuse: pulumi.Bool(true),
		Name:  pulumi.String("My CDN service"),
	})

I've played with the Reuse and force delete options, and I'm half expecting that deleting the original handmade service is necessary.

The typical flow I am hoping to achieve with this package is to create a new version of a configuration, then apply it. However, there's no version settings that I can see here, and I'm getting the following response when applying the above configuration:

Name 'My CDN service' already taken for customer '54BLTxJYhXx7qnuR5UKcuLt8Hb3n2'

Any guidance on the expected behavior and how to achieve a similar flow is appreciated.

@NisseBoman
Copy link

From a Fastly perspective using terraform to control an existing service you need to import the service first so that TF will have a state, it will try to create a new one with out provider. The import function is there for that reason to build the current state first.

This might be the reason and maby it's easier to create a new service with Pulumi? You could just remove/change the hostname of the existing service and create a new one using Pulumi.

I haven't worked with Pulumi nor do I have the abilities to do PR's to this code but advising from my knowledge of TF and Fastly.

@HelloFillip
Copy link
Author

@NisseBoman You're right in that the import feature should be used in Pulumi AFAIK. Using the Pulumi Automation API this would mean something similar to:

err := stack.Import(context, state)

Now I just need to figure out where (and how) the state is fetched from the Fastly plugin.

On the Pulumi CLI it would be something similar to:

pulumi import fastly:index:ServiceVcl "My CDN service" 

Although I'm not a Terraform user, so there's a small gap that needs to be bridged in my understanding.

@NisseBoman
Copy link

@HelloFillip
Copy link
Author

HelloFillip commented Mar 22, 2024

I resolves this. Thanks to the Terraform tip @NisseBoman. I want to provide the approach for future use cases.

When trying this approach I did receive an error that changes did not correlate, and I tried using pulumi.IgnoreChanges() to resolve this, but this failed to apply any changes.

I removed that and tried again, (with a correction to the shield as there was a typo), and it worked.

One thing to note, the Activate property did not create a new version. When this was modified to true the changes were successfully applied. I would prefer to get an update to occur without activating, but this is a workable start.

	result, err := fastly.NewServiceVcl(pulumiContext, "edge-network-delivery", &fastly.ServiceVclArgs{
		Activate: pulumi.Bool(false),
		Backends: &fastly.ServiceVclBackendArray{
			&fastly.ServiceVclBackendArgs{
				Address:             pulumi.String("***-some-web-address.dev***"),
				AutoLoadbalance:     pulumi.Bool(false),
				BetweenBytesTimeout: pulumi.Int(10000),
				ConnectTimeout:      pulumi.Int(1000),
				ErrorThreshold:      pulumi.Int(0),
				FirstByteTimeout:    pulumi.Int(15000),
				Name:                pulumi.String("Home Site"),
				OverrideHost:        pulumi.String("***-some-web-address.dev***"),
				Shield:              pulumi.String("hel-helsinki-fi"),
				SslCertHostname:     pulumi.String("*.custom-hostname.dev"),
			},
		},
		Domains: &fastly.ServiceVclDomainArray{
			&fastly.ServiceVclDomainArgs{
				Name: pulumi.String("my-domain.site"),
			},
		},
		Reuse: pulumi.Bool(true),
		Name:  pulumi.String("My CDN service"),
	}, pulumi.Import(pulumi.ID("54BLTxJYhXx7qnuR5UKcuLt8Hb3n2"))

@mjeffryes mjeffryes added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Mar 26, 2024
@iwahbe iwahbe added resolution/by-design This issue won't be fixed because the functionality is working as designed and removed needs-triage Needs attention from the triage team labels Mar 27, 2024
@iwahbe iwahbe closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

4 participants