pulumi-django-azure 1.0.9__tar.gz → 1.0.11__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pulumi-django-azure
3
- Version: 1.0.9
3
+ Version: 1.0.11
4
4
  Summary: Simply deployment of Django on Azure with Pulumi
5
5
  Author-email: Maarten Ureel <maarten@youreal.eu>
6
6
  License: MIT License
@@ -50,6 +50,18 @@ To have a proper and secure environment, we need these components:
50
50
  * Azure Key Vault per application
51
51
  * Webapp running pgAdmin
52
52
 
53
+ ## Project requirements
54
+ Your Django project should contain a folder `cicd` with these files:
55
+ * pre_build.sh: commands to be executed before building the application, for example NPM install, CSS build commands,...
56
+ * post_build.sh: commands to be executed after building the application, e.g. cleaning up.
57
+ Note that this runs in the identity of the build container, so you should not run database or storage manipulations here.
58
+ * startup.sh: commands to run the actual application. I recommend to put at least:
59
+ ```bash
60
+ python manage.py migrate
61
+ python manage.py collectstatic --noinput
62
+ gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
63
+ ```
64
+ Be sure to change `yourapplication` in the above.
53
65
  ## Installation
54
66
  This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
55
67
 
@@ -11,6 +11,18 @@ To have a proper and secure environment, we need these components:
11
11
  * Azure Key Vault per application
12
12
  * Webapp running pgAdmin
13
13
 
14
+ ## Project requirements
15
+ Your Django project should contain a folder `cicd` with these files:
16
+ * pre_build.sh: commands to be executed before building the application, for example NPM install, CSS build commands,...
17
+ * post_build.sh: commands to be executed after building the application, e.g. cleaning up.
18
+ Note that this runs in the identity of the build container, so you should not run database or storage manipulations here.
19
+ * startup.sh: commands to run the actual application. I recommend to put at least:
20
+ ```bash
21
+ python manage.py migrate
22
+ python manage.py collectstatic --noinput
23
+ gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
24
+ ```
25
+ Be sure to change `yourapplication` in the above.
14
26
  ## Installation
15
27
  This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
16
28
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pulumi-django-azure"
7
- version = "1.0.9"
7
+ version = "1.0.11"
8
8
  description = "Simply deployment of Django on Azure with Pulumi"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Maarten Ureel", email = "maarten@youreal.eu" }]
@@ -27,7 +27,7 @@ Homepage = "https://gitlab.com/MaartenUreel/pulumi-django-azure"
27
27
 
28
28
  [tool.poetry]
29
29
  name = "pulumi-django-azure"
30
- version = "1.0.9"
30
+ version = "1.0.11"
31
31
  description = "Simply deployment of Django on Azure with Pulumi"
32
32
  authors = ["Maarten Ureel <maarten@youreal.eu>"]
33
33
 
@@ -95,7 +95,7 @@ class DjangoDeployment(pulumi.ComponentResource):
95
95
  """
96
96
 
97
97
  # Put CDN in front
98
- cdn = azure.cdn.Profile(
98
+ self._cdn_profile = azure.cdn.Profile(
99
99
  f"cdn-{self._name}",
100
100
  resource_group_name=self._rg,
101
101
  location="global",
@@ -125,7 +125,7 @@ class DjangoDeployment(pulumi.ComponentResource):
125
125
  ],
126
126
  is_http_allowed=False,
127
127
  is_https_allowed=True,
128
- profile_name=cdn.name,
128
+ profile_name=self._cdn_profile.name,
129
129
  origin_host_header=endpoint_origin,
130
130
  origins=[azure.cdn.DeepCreatedOriginArgs(name="origin-storage", host_name=endpoint_origin)],
131
131
  query_string_caching_behavior=azure.cdn.QueryStringCachingBehavior.IGNORE_QUERY_STRING,
@@ -138,7 +138,7 @@ class DjangoDeployment(pulumi.ComponentResource):
138
138
  azure.cdn.CustomDomain(
139
139
  f"cdn-custom-domain-{self._name}",
140
140
  resource_group_name=self._rg,
141
- profile_name=cdn.name,
141
+ profile_name=self._cdn_profile.name,
142
142
  endpoint_name=self._cdn_endpoint.name,
143
143
  host_name=custom_host,
144
144
  )
@@ -577,6 +577,7 @@ class DjangoDeployment(pulumi.ComponentResource):
577
577
  ),
578
578
  https_only=True,
579
579
  site_config=azure.web.SiteConfigArgs(
580
+ app_command_line="cicd/startup.sh",
580
581
  always_on=True,
581
582
  health_check_path=self.HEALTH_CHECK_PATH,
582
583
  ftps_state=azure.web.FtpsState.DISABLED,
@@ -603,6 +604,8 @@ class DjangoDeployment(pulumi.ComponentResource):
603
604
  azure.web.NameValuePairArgs(name="AZURE_STORAGE_CONTAINER_MEDIA", value=media_container.name),
604
605
  # CDN
605
606
  azure.web.NameValuePairArgs(name="CDN_HOST", value=self._cdn_host),
607
+ azure.web.NameValuePairArgs(name="CDN_PROFILE", value=self._cdn_profile.name),
608
+ azure.web.NameValuePairArgs(name="CDN_ENDPOINT", value=self._cdn_endpoint.name),
606
609
  # Database settings
607
610
  azure.web.NameValuePairArgs(name="DB_HOST", value=self._pgsql.fully_qualified_domain_name),
608
611
  azure.web.NameValuePairArgs(name="DB_NAME", value=db.name),
@@ -694,6 +697,22 @@ class DjangoDeployment(pulumi.ComponentResource):
694
697
  scope=comms.id,
695
698
  )
696
699
 
700
+ # Grant the app to purge the CDN endpoint
701
+ cdn_role = self._cdn_endpoint.id.apply(
702
+ lambda scope: azure.authorization.get_role_definition(
703
+ role_definition_id="/426e0c7f-0c7e-4658-b36f-ff54d6c29b45",
704
+ scope=scope,
705
+ )
706
+ )
707
+
708
+ azure.authorization.RoleAssignment(
709
+ f"ra-{name}-cdn",
710
+ principal_id=principal_id,
711
+ principal_type=azure.authorization.PrincipalType.SERVICE_PRINCIPAL,
712
+ role_definition_id=cdn_role.id,
713
+ scope=self._cdn_endpoint.id,
714
+ )
715
+
697
716
  # Create a CORS rules for this website
698
717
  if website_hosts:
699
718
  origins = [f"https://{host}" for host in website_hosts]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pulumi-django-azure
3
- Version: 1.0.9
3
+ Version: 1.0.11
4
4
  Summary: Simply deployment of Django on Azure with Pulumi
5
5
  Author-email: Maarten Ureel <maarten@youreal.eu>
6
6
  License: MIT License
@@ -50,6 +50,18 @@ To have a proper and secure environment, we need these components:
50
50
  * Azure Key Vault per application
51
51
  * Webapp running pgAdmin
52
52
 
53
+ ## Project requirements
54
+ Your Django project should contain a folder `cicd` with these files:
55
+ * pre_build.sh: commands to be executed before building the application, for example NPM install, CSS build commands,...
56
+ * post_build.sh: commands to be executed after building the application, e.g. cleaning up.
57
+ Note that this runs in the identity of the build container, so you should not run database or storage manipulations here.
58
+ * startup.sh: commands to run the actual application. I recommend to put at least:
59
+ ```bash
60
+ python manage.py migrate
61
+ python manage.py collectstatic --noinput
62
+ gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
63
+ ```
64
+ Be sure to change `yourapplication` in the above.
53
65
  ## Installation
54
66
  This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
55
67