pulumi-django-azure 1.0.38__py3-none-any.whl → 1.0.39__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pulumi-django-azure might be problematic. Click here for more details.

@@ -1,10 +1,11 @@
1
1
  from collections.abc import Sequence
2
2
 
3
3
  import pulumi
4
+ import pulumi_azure as azure_classic
4
5
  import pulumi_azure_native as azure
5
6
  import pulumi_random
6
7
 
7
- REDIS_IMAGE = "redis:8.2"
8
+ REDIS_IMAGE = "redis:8.2-alpine"
8
9
 
9
10
 
10
11
  class HostDefinition:
@@ -478,16 +479,6 @@ class DjangoDeployment(pulumi.ComponentResource):
478
479
  },
479
480
  )
480
481
 
481
- def _get_existing_web_app_host_name_binding(self, resource_group_name: str, app_name: str, host_name: str):
482
- try:
483
- return azure.web.get_web_app_host_name_binding(
484
- resource_group_name=resource_group_name,
485
- name=app_name,
486
- host_name=host_name,
487
- )
488
- except Exception:
489
- return None
490
-
491
482
  def _add_webapp_host(
492
483
  self,
493
484
  app: azure.web.WebApp,
@@ -495,13 +486,9 @@ class DjangoDeployment(pulumi.ComponentResource):
495
486
  suffix: str,
496
487
  identifier: str,
497
488
  depends_on: Sequence[pulumi.Resource] | None = None,
498
- ):
489
+ ) -> azure.web.WebAppHostNameBinding:
499
490
  """
500
- Because of a circular dependency, we need to create the certificate and the binding in two steps.
501
- First we create a binding without a certificate,
502
- then we create the certificate and then we update the binding.
503
-
504
- The certificate needs the binding, and the binding needs the thumbprint of the certificate.
491
+ We need to use a few steps and CertificateBinding from Azure Classic to make this work.
505
492
 
506
493
  See also: https://github.com/pulumi/pulumi-azure-native/issues/578
507
494
 
@@ -514,52 +501,37 @@ class DjangoDeployment(pulumi.ComponentResource):
514
501
  if not depends_on:
515
502
  depends_on = []
516
503
 
517
- # Retrieve the existing binding (None if it doesn't exist)
518
- existing_binding = pulumi.Output.all(app.resource_group, app.name, host).apply(
519
- lambda args: self._get_existing_web_app_host_name_binding(
520
- resource_group_name=args[0],
521
- app_name=args[1],
522
- host_name=args[2],
523
- )
504
+ # Create a binding without a certificate
505
+ binding = azure.web.WebAppHostNameBinding(
506
+ f"host-binding-{suffix}-{identifier}",
507
+ resource_group_name=self._rg,
508
+ name=app.name,
509
+ host_name=host,
510
+ ssl_state=azure.web.SslState.DISABLED,
511
+ # Ignore changes in SSL state and thumbprint
512
+ opts=pulumi.ResourceOptions(depends_on=depends_on, ignore_changes=["ssl_state", "thumbprint"]),
524
513
  )
525
514
 
526
- # Create an inline function that we will invoke through the Output.apply lambda
527
- def _create_binding_with_cert(existing_binding):
528
- if existing_binding:
529
- # Create a managed certificate
530
- # This will work because the binding exists actually
531
- certificate = azure.web.Certificate(
532
- f"cert-{suffix}-{identifier}",
533
- resource_group_name=self._rg,
534
- server_farm_id=app.server_farm_id,
535
- canonical_name=host,
536
- host_names=[host],
537
- opts=pulumi.ResourceOptions(depends_on=depends_on),
538
- )
539
-
540
- # Create a new binding, replacing the old one,
541
- # with the certificate
542
- azure.web.WebAppHostNameBinding(
543
- f"host-binding-{suffix}-{identifier}",
544
- resource_group_name=self._rg,
545
- name=app.name,
546
- host_name=host,
547
- ssl_state=azure.web.SslState.SNI_ENABLED,
548
- thumbprint=certificate.thumbprint,
549
- opts=pulumi.ResourceOptions(depends_on=depends_on),
550
- )
515
+ # Create a certificate that depends on the binding
516
+ certificate = azure.web.Certificate(
517
+ f"cert-{suffix}-{identifier}",
518
+ resource_group_name=self._rg,
519
+ server_farm_id=app.server_farm_id,
520
+ canonical_name=host,
521
+ opts=pulumi.ResourceOptions(depends_on=[binding] + depends_on),
522
+ )
551
523
 
552
- else:
553
- # Create a binding without a certificate
554
- azure.web.WebAppHostNameBinding(
555
- f"host-binding-{suffix}-{identifier}",
556
- resource_group_name=self._rg,
557
- name=app.name,
558
- host_name=host,
559
- opts=pulumi.ResourceOptions(depends_on=depends_on),
560
- )
524
+ # Create CertificateBinding from Azure Classic to link it together
525
+ # Inspired by https://github.com/pulumi/pulumi-azure-native/issues/578#issuecomment-2705952672
526
+ azure_classic.appservice.CertificateBinding(
527
+ f"cert-binding-{suffix}-{identifier}",
528
+ hostname_binding_id=binding.id,
529
+ certificate_id=certificate.id,
530
+ ssl_state="SniEnabled",
531
+ opts=pulumi.ResourceOptions(depends_on=depends_on, ignore_changes=["hostname_binding_id"]),
532
+ )
561
533
 
562
- existing_binding.apply(_create_binding_with_cert)
534
+ return binding
563
535
 
564
536
  def _create_comms_dns_records(self, suffix, host: HostDefinition, records: dict) -> list[azure.dns.RecordSet]:
565
537
  created_records = []
@@ -773,7 +745,8 @@ class DjangoDeployment(pulumi.ComponentResource):
773
745
  comms_domains: list[HostDefinition] | None = None,
774
746
  dedicated_app_service_sku: azure.web.SkuDescriptionArgs | None = None,
775
747
  vault_administrators: list[str] | None = None,
776
- redis_cache: bool = True,
748
+ redis_sidecar: bool = True,
749
+ django_tasks: bool = True,
777
750
  startup_timeout: int = 300,
778
751
  ) -> azure.web.WebApp:
779
752
  """
@@ -794,7 +767,7 @@ class DjangoDeployment(pulumi.ComponentResource):
794
767
  :param comms_domains: The list of custom domains for the E-mail Communication Services (optional).
795
768
  :param dedicated_app_service_sku: The SKU for the dedicated App Service Plan (optional).
796
769
  :param vault_administrators: The principal IDs of the vault administrators (optional).
797
- :param redis_cache: Whether to create a Redis sidecar container.
770
+ :param redis_sidecar: Whether to create a Redis sidecar container.
798
771
  :param startup_timeout: The startup timeout for the App Service (default is 300 seconds).
799
772
  """
800
773
 
@@ -825,9 +798,15 @@ class DjangoDeployment(pulumi.ComponentResource):
825
798
  )
826
799
 
827
800
  # Redis cache environment variable
828
- if redis_cache:
801
+ if redis_sidecar:
829
802
  environment_variables["REDIS_SIDECAR"] = "true"
830
803
 
804
+ if django_tasks:
805
+ if not redis_sidecar:
806
+ raise ValueError("django-tasks requires redis-sidecar to be enabled.")
807
+
808
+ environment_variables["DJANGO_TASKS"] = "true"
809
+
831
810
  # Communication Services (optional)
832
811
  if comms_data_location:
833
812
  if not comms_domains:
@@ -891,6 +870,7 @@ class DjangoDeployment(pulumi.ComponentResource):
891
870
  python_version=python_version,
892
871
  # scm_type=azure.web.ScmType.EXTERNAL_GIT,
893
872
  linux_fx_version=f"PYTHON|{python_version}",
873
+ http20_enabled=True,
894
874
  app_settings=[
895
875
  # Startup settings
896
876
  azure.web.NameValuePairArgs(name="WEBSITES_CONTAINER_START_TIME_LIMIT", value=str(startup_timeout)),
@@ -929,13 +909,13 @@ class DjangoDeployment(pulumi.ComponentResource):
929
909
  )
930
910
 
931
911
  # Redis cache
932
- if redis_cache:
912
+ if redis_sidecar:
933
913
  azure.web.WebAppSiteContainer(
934
- f"redis-cache-{name}-{self._name}",
914
+ f"redis-sidecar-{name}-{self._name}",
935
915
  resource_group_name=self._rg,
936
916
  name=app.name,
937
917
  is_main=False,
938
- container_name="redis-cache",
918
+ container_name="redis-sidecar",
939
919
  image=REDIS_IMAGE,
940
920
  target_port="6379",
941
921
  )
@@ -962,8 +942,10 @@ class DjangoDeployment(pulumi.ComponentResource):
962
942
 
963
943
  pulumi.export(f"{name}_deploy_url", pulumi.Output.concat(credentials.scm_uri, "/deploy"))
964
944
 
945
+ bindings = []
965
946
  for host in website_hosts:
966
- dependencies = []
947
+ # Only one binding can be created at a time, so we need to depend on the previous one.
948
+ dependencies = bindings or []
967
949
 
968
950
  if host.zone:
969
951
  # Create a DNS record in the zone.
@@ -1004,7 +986,7 @@ class DjangoDeployment(pulumi.ComponentResource):
1004
986
  dependencies.append(txt_validation)
1005
987
 
1006
988
  # Add the host with optional dependencies
1007
- self._add_webapp_host(
989
+ binding = self._add_webapp_host(
1008
990
  app=app,
1009
991
  host=host.full_host,
1010
992
  suffix=f"{name}-{self._name}",
@@ -1012,6 +994,8 @@ class DjangoDeployment(pulumi.ComponentResource):
1012
994
  depends_on=dependencies,
1013
995
  )
1014
996
 
997
+ bindings.append(binding)
998
+
1015
999
  # To enable deployment from GitLab
1016
1000
  azure.web.WebAppSourceControl(
1017
1001
  f"app-{name}-sourcecontrol-{self._name}",
@@ -151,3 +151,20 @@ if REDIS_SIDECAR:
151
151
  },
152
152
  },
153
153
  }
154
+
155
+
156
+ # Django tasks
157
+ DJANGO_TASKS = env("DJANGO_TASKS", default=False)
158
+ if DJANGO_TASKS and REDIS_SIDECAR:
159
+ RQ_QUEUES = {
160
+ "default": {
161
+ "USE_REDIS_CACHE": "default",
162
+ "QUEUES": ["default"],
163
+ }
164
+ }
165
+
166
+ TASKS = {
167
+ "default": {
168
+ "BACKEND": "django_tasks.backends.rq.RQBackend",
169
+ }
170
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pulumi-django-azure
3
- Version: 1.0.38
3
+ Version: 1.0.39
4
4
  Summary: Simply deployment of Django on Azure with Pulumi
5
5
  License-Expression: MIT
6
6
  Keywords: django,pulumi,azure
@@ -9,7 +9,7 @@ Author-email: maarten@youreal.eu
9
9
  Requires-Python: >=3.11,<3.14
10
10
  Classifier: Programming Language :: Python
11
11
  Classifier: Programming Language :: Python :: 3
12
- Requires-Dist: azure-identity (>=1.25.0,<2.0.0)
12
+ Requires-Dist: azure-identity (>=1.25.1,<2.0.0)
13
13
  Requires-Dist: azure-keyvault-secrets (>=4.10.0,<5.0.0)
14
14
  Requires-Dist: azure-mgmt-cdn (>=13.1.1,<14.0.0)
15
15
  Requires-Dist: azure-mgmt-resource (>=24.0.0,<25.0.0)
@@ -18,9 +18,11 @@ Requires-Dist: django-azure-communication-email (>=1.4.0,<2.0.0)
18
18
  Requires-Dist: django-environ (>=0.12.0,<0.13.0)
19
19
  Requires-Dist: django-redis (>=6.0.0,<7.0.0)
20
20
  Requires-Dist: django-storages[azure] (>=1.14.6,<2.0.0)
21
- Requires-Dist: pulumi (>=3.199.0)
21
+ Requires-Dist: django-tasks[rq] (>=0.8.0,<0.10.0)
22
+ Requires-Dist: pulumi (>=3.203.0)
23
+ Requires-Dist: pulumi-azure (>=6.28.0,<7.0.0)
22
24
  Requires-Dist: pulumi-azure-native (>=3.8.0)
23
- Requires-Dist: pulumi-random (>=4.18.3)
25
+ Requires-Dist: pulumi-random (>=4.18.4)
24
26
  Requires-Dist: redis[hiredis] (>=6.4.0,<7.0.0)
25
27
  Requires-Dist: tenacity (>=9.1.2,<10.0.0)
26
28
  Project-URL: Homepage, https://gitlab.com/MaartenUreel/pulumi-django-azure
@@ -1,13 +1,13 @@
1
1
  pulumi_django_azure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  pulumi_django_azure/azure_helper.py,sha256=vZLIVZo44EP1-GGeq0XLJ10c42wJDDpKSL5-_sVgUzA,3053
3
3
  pulumi_django_azure/context_processors.py,sha256=Qm2e_WBipJYMDH3clYAAaHvEDkG8au2czSQqRkS5928,1136
4
- pulumi_django_azure/django_deployment.py,sha256=bVDEHrd7KeT6CAuLj0gozn_qSnfSBmm7iRk_6Yy2A34,46655
4
+ pulumi_django_azure/django_deployment.py,sha256=0Lb4Ug35Mf0_66CT5KAXS5tMeHbBau2rTrWlKJygNYc,45919
5
5
  pulumi_django_azure/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pulumi_django_azure/management/commands/purge_cache.py,sha256=yjMoNvEPFmtuZctOKXMUacfKJLlTC9xfF-0W-IH3kF0,488
7
7
  pulumi_django_azure/management/commands/purge_cdn.py,sha256=8iLuqjndvreTHXRp37sjpvcNltdGTpwhY9YiQokS_P0,2095
8
8
  pulumi_django_azure/management/commands/test_redis.py,sha256=_jQXmv48NSPVGrgGZTmASWm0WAWYhqt9HaE3XdJ22U4,10225
9
9
  pulumi_django_azure/middleware.py,sha256=XykZAmilyCaZR_5mM950h2WI4053HRqr95LGV1p8uR0,2472
10
- pulumi_django_azure/settings.py,sha256=hneKnLgm-gzxgX724wEs1rJxK6oq7W5EgT2sJyx7bxY,5231
11
- pulumi_django_azure-1.0.38.dist-info/METADATA,sha256=LKKnOR0zT3RVJ0kGIbE1CnLRyJ9BCX2stNO_o_oH-LU,9609
12
- pulumi_django_azure-1.0.38.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
13
- pulumi_django_azure-1.0.38.dist-info/RECORD,,
10
+ pulumi_django_azure/settings.py,sha256=nHQJRTefcCs0W9on8EkO1tbrJLKAhjRAfAujRN77oDU,5595
11
+ pulumi_django_azure-1.0.39.dist-info/METADATA,sha256=ROXjYcWKx-hqOC6Lrr_-ipPKaScp-VEnDwc74e7xGt4,9705
12
+ pulumi_django_azure-1.0.39.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
13
+ pulumi_django_azure-1.0.39.dist-info/RECORD,,