Skip to content

Commit 522e96e

Browse files
committed
Updated IaC to use non-deprecated Cloudflare stuff
1 parent 63f21c0 commit 522e96e

File tree

8 files changed

+36
-47
lines changed

8 files changed

+36
-47
lines changed

infra/pulumi-infra-deploy/StackBuilders/RouteFilterWorker/RouteFilterInfrastructure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public record RouteFilterInfrastructure(
1111
{
1212

1313
public record WorkerInfrastructure(
14-
Cloudflare.WorkerScript Script, Cloudflare.WorkerRoute workerRoute);
14+
Cloudflare.WorkersScript Script, Cloudflare.WorkersRoute workerRoute);
1515
}

infra/pulumi-infra-deploy/StackBuilders/RouteFilterWorker/RouteFilterStackBuilder.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using ProgrammerAl.Site.IaC.Utilities;
77
using ProgrammerAl.Site.IaC.Config.GlobalConfigs;
88
using ProgrammerAl.Site.IaC.StackBuilders.StorageApi;
9+
using Pulumi.Cloudflare.Inputs;
910

1011
namespace ProgrammerAl.Site.IaC.StackBuilders.RouteFilterWorker;
1112

@@ -26,29 +27,30 @@ public RouteFilterInfrastructure GenerateResources()
2627
private WorkerInfrastructure CreateWorker(string serviceName, Provider provider)
2728
{
2829
var name = $"{serviceName}-script";
29-
var apiScript = new WorkerScript(name, new()
30+
var apiScript = new WorkersScript(name, new()
3031
{
3132
AccountId = GlobalConfig.CloudflareConfig.AccountId,
32-
Name = GlobalConfig.RouteFilterWorkerConfig.ServiceName,
33+
ScriptName = GlobalConfig.RouteFilterWorkerConfig.ServiceName,
3334
Content = File.ReadAllText(GlobalConfig.DeploymentPackagesConfig.RouteFilterWorkerFilePath),
34-
Module = true,
35-
PlainTextBindings = new[]
35+
MainModule = name,
36+
Bindings = new[]
3637
{
37-
new Pulumi.Cloudflare.Inputs.WorkerScriptPlainTextBindingArgs
38+
new WorkersScriptBindingArgs
3839
{
3940
Name = "STORAGE_API_ENDPOINT",
4041
Text = StorageApiInfra.Domain.HttpsEndpoint,
42+
Type = "plain_text",
4143
},
4244
}
4345
}, new CustomResourceOptions
4446
{
4547
Provider = provider
4648
});
4749

48-
var workerRoute = new WorkerRoute($"{serviceName}-route", new WorkerRouteArgs
50+
var workerRoute = new WorkersRoute($"{serviceName}-route", new WorkersRouteArgs
4951
{
5052
ZoneId = GlobalConfig.RouteFilterWorkerConfig.CloudflareZoneId,
51-
ScriptName = apiScript.Name,
53+
Script = apiScript.ScriptName,
5254
Pattern = GlobalConfig.RouteFilterWorkerConfig.RoutePattern,
5355

5456
}, new CustomResourceOptions

infra/pulumi-infra-deploy/StackBuilders/StorageApi/StorageApiInfrastructure.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public record StorageInfrastructure(
1616
Cloudflare.R2Bucket Bucket);
1717

1818
public record ApiInfrastructure(
19-
Cloudflare.WorkerScript Script,
19+
Cloudflare.WorkersScript Script,
2020
Pulumi.Random.RandomUuid AdminAuthToken);
2121

2222
public record DomainInfrastructure(
23-
Cloudflare.WorkerDomain WorkerDomain,
23+
Cloudflare.WorkersCustomDomain WorkerDomain,
2424
Output<string> HttpsEndpoint);
2525
}

infra/pulumi-infra-deploy/StackBuilders/StorageApi/StorageApiStackBuilder.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ private ApiInfrastructure CreateApi(StorageInfrastructure storageInfra, string s
5151
Pulumi.Log.Info($"Using storage api js file from: {GlobalConfig.DeploymentPackagesConfig.StorageApiWorkerFilePath}");
5252

5353
var name = $"{serviceName}-script";
54-
var apiScript = new WorkerScript(name, new()
54+
var apiScript = new WorkersScript(name, new()
5555
{
5656
AccountId = GlobalConfig.CloudflareConfig.AccountId,
57-
Name = GlobalConfig.StorageApiConfig.ServiceName,
57+
ScriptName = GlobalConfig.StorageApiConfig.ServiceName,
5858
Content = File.ReadAllText(GlobalConfig.DeploymentPackagesConfig.StorageApiWorkerFilePath),
59-
Module = true,
60-
R2BucketBindings = new[]
59+
MainModule = name,
60+
Bindings = new[]
6161
{
62-
new Cloudflare.Inputs.WorkerScriptR2BucketBindingArgs
62+
new Cloudflare.Inputs.WorkersScriptBindingArgs
6363
{
6464
Name = "STORAGE_BUCKET",
6565
BucketName = storageInfra.Bucket.Name,
66+
Type = "r2_bucket"
6667
},
67-
},
68-
SecretTextBindings = new[]
69-
{
70-
new Cloudflare.Inputs.WorkerScriptSecretTextBindingArgs
68+
new Cloudflare.Inputs.WorkersScriptBindingArgs
7169
{
7270
Name = "ADMIN_TOKEN",
7371
Text = adminAuthToken.Result,
72+
Type = "secret_text",
7473
},
75-
},
74+
}
75+
7676
}, new CustomResourceOptions
7777
{
7878
Provider = provider
@@ -85,12 +85,13 @@ private DomainInfrastructure GenerateDomainEntries(ApiInfrastructure apiInfra, s
8585
{
8686
var domainEndpoint = $"{GlobalConfig.StorageApiConfig.ServiceName}.{GlobalConfig.StorageApiConfig.ApiDomain}".ToLower();
8787

88-
var workerDomain = new WorkerDomain($"{serviceName}-worker-domain", new()
88+
var workerDomain = new WorkersCustomDomain($"{serviceName}-worker-domain", new()
8989
{
9090
AccountId = GlobalConfig.CloudflareConfig.AccountId,
9191
ZoneId = GlobalConfig.StorageApiConfig.CloudflareZoneId,
92-
Service = apiInfra.Script.Name,
93-
Hostname = domainEndpoint
92+
Service = apiInfra.Script.ScriptName,
93+
Hostname = domainEndpoint,
94+
Environment = "production"//We don't use cloudflare's environments, so just put "production" here because something is required
9495
}, new CustomResourceOptions
9596
{
9697
Provider = provider

infra/pulumi-infra-deploy/StackBuilders/Website/WebsiteInfrastructure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public record WebsiteInfrastructure(
1212
public record CloudflarePagesApp(Pulumi.Cloudflare.PagesProject PagesProject);
1313

1414
public record DomainsInfrastructure(
15-
Pulumi.Cloudflare.Record DomainRecord,
15+
Pulumi.Cloudflare.DnsRecord DomainRecord,
1616
Pulumi.Cloudflare.PagesDomain PagesDomain,
1717
Output<string> FullEndpoint);
1818
}

infra/pulumi-infra-deploy/StackBuilders/Website/WebsiteStackBuilder.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,19 @@ private DomainsInfrastructure GenerateDomainEntries(CloudflarePagesApp webClient
148148
var pagesDomain = new Cloudflare.PagesDomain("public-web-app-pages-domain", new()
149149
{
150150
AccountId = GlobalConfig.CloudflareConfig.AccountId,
151-
Domain = pagesDomainEndpoint,
151+
Name = pagesDomainEndpoint,
152152
ProjectName = webClientInfra.PagesProject.Name,
153153
}, new CustomResourceOptions
154154
{
155155
Provider = provider
156156
});
157157

158-
var record = new Cloudflare.Record("website-cname", new Cloudflare.RecordArgs
158+
var record = new Cloudflare.DnsRecord("website-cname", new Cloudflare.DnsRecordArgs
159159
{
160160
Name = pagesDomainEndpoint,
161-
Value = webClientInfra.PagesProject.Subdomain,
161+
Content = webClientInfra.PagesProject.Subdomain,
162162
ZoneId = GlobalConfig.WebClientInfraConfig.CloudflareZoneId,
163163
Proxied = true,
164-
AllowOverwrite = true,
165164
Type = "CNAME",
166165
Ttl = 1,//Has to be set to 1 because this is proxied
167166
}, new CustomResourceOptions

infra/pulumi-infra-deploy/Utilities/AzureUtilities.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Text;
99
using System.Threading.Tasks;
1010
using Pulumi.AzureNative.Resources;
11-
using Pulumi.AzureNative.Devices;
1211
using System.Collections.Immutable;
1312
using Pulumi.AzureAD.Outputs;
1413

@@ -93,18 +92,6 @@ public static Output<string> GetBlobContainerUrl(BlobContainer container, Storag
9392
});
9493
}
9594

96-
public static Output<string> GetAzureIotHubOwnerConnectionString(ResourceGroup resourceGroup, Input<string> iotHubName)
97-
{
98-
return ListIotHubResourceKeysForKeyName.Invoke(
99-
new ListIotHubResourceKeysForKeyNameInvokeArgs
100-
{
101-
KeyName = "iothubowner",
102-
ResourceGroupName = resourceGroup.Name.Apply(x => x),
103-
ResourceName = iotHubName
104-
})
105-
.Apply(x => Output.Format($"HostName={iotHubName.Apply(y => y)}.azure-devices.net;SharedAccessKeyName={x.KeyName};SharedAccessKey={x.PrimaryKey}"));
106-
}
107-
10895
public static string GenerateBlobFileResourceName(FileInfo file)
10996
{
11097
return file.FullName.Replace("\\", "_").Replace("/", "_").Replace(" ", "_");

infra/pulumi-infra-deploy/pulumi-infra-deploy.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="Azure.Identity" Version="1.13.1" />
13+
<PackageReference Include="Azure.Identity" Version="1.14.0" />
1414
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
15-
<PackageReference Include="Pulumi.AzureNative" Version="2.74.0" />
16-
<PackageReference Include="Pulumi.AzureAD" Version="6.0.1" />
17-
<PackageReference Include="Pulumi.Cloudflare" Version="5.43.1" />
18-
<PackageReference Include="Pulumi.Command" Version="1.0.1" />
19-
<PackageReference Include="Pulumi.Random" Version="4.16.7" />
15+
<PackageReference Include="Pulumi.AzureNative" Version="3.5.0" />
16+
<PackageReference Include="Pulumi.AzureAD" Version="6.5.1" />
17+
<PackageReference Include="Pulumi.Cloudflare" Version="6.2.1" />
18+
<PackageReference Include="Pulumi.Command" Version="1.1.0" />
19+
<PackageReference Include="Pulumi.Random" Version="4.18.2" />
2020
</ItemGroup>
2121
<PropertyGroup>
2222
<NuGetAudit>true</NuGetAudit>

0 commit comments

Comments
 (0)