pulumi-django-azure 1.0.4__tar.gz → 1.0.7__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.
- {pulumi-django-azure-1.0.4/src/pulumi_django_azure.egg-info → pulumi-django-azure-1.0.7}/PKG-INFO +5 -1
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/README.md +4 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/pyproject.toml +2 -2
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure/django_deployment.py +81 -8
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7/src/pulumi_django_azure.egg-info}/PKG-INFO +5 -1
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/LICENSE +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/setup.cfg +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure/__init__.py +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure.egg-info/SOURCES.txt +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure.egg-info/dependency_links.txt +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure.egg-info/requires.txt +0 -0
- {pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure.egg-info/top_level.txt +0 -0
{pulumi-django-azure-1.0.4/src/pulumi_django_azure.egg-info → pulumi-django-azure-1.0.7}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pulumi-django-azure
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
@@ -45,6 +45,7 @@ To have a proper and secure environment, we need these components:
|
|
|
45
45
|
* Storage account for media and static files
|
|
46
46
|
* CDN endpoint in front with a domain name of our choosing
|
|
47
47
|
* PostgreSQL server
|
|
48
|
+
* Azure Communication Services to send e-mails
|
|
48
49
|
* Webapp with multiple custom host names and managed SSL for the website itself
|
|
49
50
|
* Webapp running pgAdmin
|
|
50
51
|
|
|
@@ -101,6 +102,8 @@ django.add_django_website(
|
|
|
101
102
|
repository_branch="main",
|
|
102
103
|
website_hosts=["example.com", "www.example.com"],
|
|
103
104
|
django_settings_module="mywebsite.settings.production",
|
|
105
|
+
comms_data_location="europe",
|
|
106
|
+
comms_domains=["mydomain.com"],
|
|
104
107
|
)
|
|
105
108
|
|
|
106
109
|
django.add_database_administrator(
|
|
@@ -120,6 +123,7 @@ django.add_database_administrator(
|
|
|
120
123
|
6. Re-deploy with custom hosts
|
|
121
124
|
7. Re-deploy once more to enable HTTPS on website domains
|
|
122
125
|
8. Manually activate HTTPS on the CDN host
|
|
126
|
+
9. Go to the e-mail communications service on Azure and configure DKIM, SPF,... for your custom domains.
|
|
123
127
|
|
|
124
128
|
## Custom domain name for CDN
|
|
125
129
|
When deploying the first time, you will get a `cdn_cname` output. You need to create a CNAME to this domain before the deployment of the custom domain will succeed.
|
|
@@ -6,6 +6,7 @@ To have a proper and secure environment, we need these components:
|
|
|
6
6
|
* Storage account for media and static files
|
|
7
7
|
* CDN endpoint in front with a domain name of our choosing
|
|
8
8
|
* PostgreSQL server
|
|
9
|
+
* Azure Communication Services to send e-mails
|
|
9
10
|
* Webapp with multiple custom host names and managed SSL for the website itself
|
|
10
11
|
* Webapp running pgAdmin
|
|
11
12
|
|
|
@@ -62,6 +63,8 @@ django.add_django_website(
|
|
|
62
63
|
repository_branch="main",
|
|
63
64
|
website_hosts=["example.com", "www.example.com"],
|
|
64
65
|
django_settings_module="mywebsite.settings.production",
|
|
66
|
+
comms_data_location="europe",
|
|
67
|
+
comms_domains=["mydomain.com"],
|
|
65
68
|
)
|
|
66
69
|
|
|
67
70
|
django.add_database_administrator(
|
|
@@ -81,6 +84,7 @@ django.add_database_administrator(
|
|
|
81
84
|
6. Re-deploy with custom hosts
|
|
82
85
|
7. Re-deploy once more to enable HTTPS on website domains
|
|
83
86
|
8. Manually activate HTTPS on the CDN host
|
|
87
|
+
9. Go to the e-mail communications service on Azure and configure DKIM, SPF,... for your custom domains.
|
|
84
88
|
|
|
85
89
|
## Custom domain name for CDN
|
|
86
90
|
When deploying the first time, you will get a `cdn_cname` output. You need to create a CNAME to this domain before the deployment of the custom domain will succeed.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pulumi-django-azure"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.7"
|
|
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.
|
|
30
|
+
version = "1.0.7"
|
|
31
31
|
description = "Simply deployment of Django on Azure with Pulumi"
|
|
32
32
|
authors = ["Maarten Ureel <maarten@youreal.eu>"]
|
|
33
33
|
|
{pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure/django_deployment.py
RENAMED
|
@@ -14,6 +14,7 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
14
14
|
tenant_id: str,
|
|
15
15
|
resource_group_name: pulumi.Input[str],
|
|
16
16
|
vnet: azure.network.VirtualNetwork,
|
|
17
|
+
pgsql_sku: azure.dbforpostgresql.SkuArgs,
|
|
17
18
|
pgsql_ip_prefix: str,
|
|
18
19
|
appservice_ip_prefix: str,
|
|
19
20
|
app_service_sku: azure.web.SkuDescriptionArgs,
|
|
@@ -28,11 +29,13 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
28
29
|
:param tenant_id: The Entra tenant ID for the database authentication.
|
|
29
30
|
:param resource_group_name: The resource group name to create the resources in.
|
|
30
31
|
:param vnet: The virtual network to create the subnets in.
|
|
32
|
+
:param pgsql_sku: The SKU for the PostgreSQL server.
|
|
31
33
|
:param pgsql_ip_prefix: The IP prefix for the PostgreSQL subnet.
|
|
32
34
|
:param appservice_ip_prefix: The IP prefix for the app service subnet.
|
|
33
35
|
:param app_service_sku: The SKU for the app service plan.
|
|
34
36
|
:param storage_account_name: The name of the storage account. Should be unique across Azure.
|
|
35
37
|
:param cdn_host: A custom CDN host name (optional)
|
|
38
|
+
:param comms_data_location: The data location for the Communication Services (optional if you don't need it)
|
|
36
39
|
:param opts: The resource options
|
|
37
40
|
"""
|
|
38
41
|
|
|
@@ -50,7 +53,7 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
50
53
|
self._cdn_host = self._create_cdn(custom_host=cdn_host)
|
|
51
54
|
|
|
52
55
|
# PostgreSQL resources
|
|
53
|
-
self._create_database(ip_prefix=pgsql_ip_prefix)
|
|
56
|
+
self._create_database(sku=pgsql_sku, ip_prefix=pgsql_ip_prefix)
|
|
54
57
|
|
|
55
58
|
# Subnet for the apps
|
|
56
59
|
self._app_subnet = self._create_subnet(
|
|
@@ -145,7 +148,7 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
145
148
|
# Return the default CDN host name
|
|
146
149
|
return self._cdn_endpoint.host_name
|
|
147
150
|
|
|
148
|
-
def _create_database(self, ip_prefix: str):
|
|
151
|
+
def _create_database(self, sku: azure.dbforpostgresql.SkuArgs, ip_prefix: str):
|
|
149
152
|
# Create subnet for PostgreSQL
|
|
150
153
|
subnet = self._create_subnet(
|
|
151
154
|
name="pgsql",
|
|
@@ -176,10 +179,7 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
176
179
|
self._pgsql = azure.dbforpostgresql.Server(
|
|
177
180
|
f"pgsql-{self._name}",
|
|
178
181
|
resource_group_name=self._rg,
|
|
179
|
-
sku=
|
|
180
|
-
name="Standard_B2s",
|
|
181
|
-
tier=azure.dbforpostgresql.SkuTier.BURSTABLE,
|
|
182
|
-
),
|
|
182
|
+
sku=sku,
|
|
183
183
|
version="16",
|
|
184
184
|
auth_config=azure.dbforpostgresql.AuthConfigArgs(
|
|
185
185
|
password_auth=azure.dbforpostgresql.PasswordAuthEnum.DISABLED,
|
|
@@ -260,8 +260,6 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
260
260
|
# azure.web.NameValuePairArgs(name="WEBSITE_HTTPLOGGING_RETENTION_DAYS", value="7"),
|
|
261
261
|
# pgAdmin settings
|
|
262
262
|
azure.web.NameValuePairArgs(name="PGADMIN_DISABLE_POSTFIX", value="true"),
|
|
263
|
-
azure.web.NameValuePairArgs(name="PGADMIN_AUTHENTICATION_SOURCES", value="['oauth2, 'internal']"),
|
|
264
|
-
azure.web.NameValuePairArgs(name="PGADMIN_OAUTH2_NAME", value="azure"),
|
|
265
263
|
azure.web.NameValuePairArgs(name="PGADMIN_DEFAULT_EMAIL", value="dbadmin@dbadmin.net"),
|
|
266
264
|
azure.web.NameValuePairArgs(name="PGADMIN_DEFAULT_PASSWORD", value="dbadmin"),
|
|
267
265
|
],
|
|
@@ -348,6 +346,51 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
348
346
|
host_name=host,
|
|
349
347
|
)
|
|
350
348
|
|
|
349
|
+
def _add_webapp_comms(self, data_location: str, domains: list[str], suffix: str) -> azure.communication.CommunicationService:
|
|
350
|
+
email_service = azure.communication.EmailService(
|
|
351
|
+
f"comms-email-{suffix}",
|
|
352
|
+
resource_group_name=self._rg,
|
|
353
|
+
location="global",
|
|
354
|
+
data_location=data_location,
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
domain_resources = []
|
|
358
|
+
if domains:
|
|
359
|
+
# Add our own custom domains
|
|
360
|
+
for domain in domains:
|
|
361
|
+
safe_host = domain.replace(".", "-")
|
|
362
|
+
d = azure.communication.Domain(
|
|
363
|
+
f"comms-email-domain-{suffix}-{safe_host}",
|
|
364
|
+
resource_group_name=self._rg,
|
|
365
|
+
location="global",
|
|
366
|
+
domain_management=azure.communication.DomainManagement.CUSTOMER_MANAGED,
|
|
367
|
+
domain_name=domain,
|
|
368
|
+
email_service_name=email_service.name,
|
|
369
|
+
)
|
|
370
|
+
domain_resources.append(d.id.apply(lambda n: n))
|
|
371
|
+
else:
|
|
372
|
+
# Add an Azure managed domain
|
|
373
|
+
d = azure.communication.Domain(
|
|
374
|
+
f"comms-email-domain-{suffix}-azure",
|
|
375
|
+
resource_group_name=self._rg,
|
|
376
|
+
location="global",
|
|
377
|
+
domain_management=azure.communication.DomainManagement.AZURE_MANAGED,
|
|
378
|
+
domain_name="AzureManagedDomain",
|
|
379
|
+
email_service_name=email_service.name,
|
|
380
|
+
)
|
|
381
|
+
domain_resources.append(d.id.apply(lambda n: n))
|
|
382
|
+
|
|
383
|
+
# Create Communication Services and link the domains
|
|
384
|
+
comm_service = azure.communication.CommunicationService(
|
|
385
|
+
f"comms-{suffix}",
|
|
386
|
+
resource_group_name=self._rg,
|
|
387
|
+
location="global",
|
|
388
|
+
data_location=data_location,
|
|
389
|
+
linked_domains=domain_resources,
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
return comm_service
|
|
393
|
+
|
|
351
394
|
def _get_storage_account_access_keys(
|
|
352
395
|
self, storage_account: azure.storage.StorageAccount
|
|
353
396
|
) -> Sequence[azure.storage.outputs.StorageAccountKeyResponse]:
|
|
@@ -394,6 +437,8 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
394
437
|
website_hosts: list[str],
|
|
395
438
|
django_settings_module: str,
|
|
396
439
|
environment_variables: dict[str, str] = {},
|
|
440
|
+
comms_data_location: Optional[str] = None,
|
|
441
|
+
comms_domains: Optional[list[str]] = [],
|
|
397
442
|
) -> azure.web.WebApp:
|
|
398
443
|
"""
|
|
399
444
|
Create a Django website with it's own database and storage containers.
|
|
@@ -405,6 +450,8 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
405
450
|
:param website_hosts: The list of custom host names for the website.
|
|
406
451
|
:param django_settings_module: The Django settings module to load.
|
|
407
452
|
:param environment_variables: A dictionary of environment variables to set.
|
|
453
|
+
:param comms_data_location: The data location for the Communication Services (optional if you don't need it).
|
|
454
|
+
:param comms_domains: The list of custom domains for the E-mail Communication Services (optional).
|
|
408
455
|
"""
|
|
409
456
|
|
|
410
457
|
# Create a database
|
|
@@ -433,6 +480,14 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
433
480
|
container_name=f"{name}-static",
|
|
434
481
|
)
|
|
435
482
|
|
|
483
|
+
# Communication Services (optional)
|
|
484
|
+
if comms_data_location:
|
|
485
|
+
comms = self._add_webapp_comms(comms_data_location, comms_domains, f"{name}-{self._name}")
|
|
486
|
+
# Add the domains as environment variable
|
|
487
|
+
environment_variables["AZURE_COMMUNICATION_SERVICE"] = comms.name
|
|
488
|
+
else:
|
|
489
|
+
comms = None
|
|
490
|
+
|
|
436
491
|
# Create a Django Secret Key (random)
|
|
437
492
|
secret_key = pulumi_random.RandomString(f"django-secret-{name}-{self._name}", length=50)
|
|
438
493
|
|
|
@@ -534,6 +589,24 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
534
589
|
scope=self._storage_account.id,
|
|
535
590
|
)
|
|
536
591
|
|
|
592
|
+
# Grant the app to send e-mails
|
|
593
|
+
if comms:
|
|
594
|
+
comms_role = comms.id.apply(
|
|
595
|
+
lambda scope: azure.authorization.get_role_definition(
|
|
596
|
+
# Contributor
|
|
597
|
+
role_definition_id="b24988ac-6180-42a0-ab88-20f7382dd24c",
|
|
598
|
+
scope=scope,
|
|
599
|
+
)
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
azure.authorization.RoleAssignment(
|
|
603
|
+
f"ra-{name}-comms",
|
|
604
|
+
principal_id=principal_id,
|
|
605
|
+
principal_type=azure.authorization.PrincipalType.SERVICE_PRINCIPAL,
|
|
606
|
+
role_definition_id=comms_role.id,
|
|
607
|
+
scope=comms.id,
|
|
608
|
+
)
|
|
609
|
+
|
|
537
610
|
# Create a CORS rules for this website
|
|
538
611
|
if website_hosts:
|
|
539
612
|
origins = [f"https://{host}" for host in website_hosts]
|
{pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7/src/pulumi_django_azure.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pulumi-django-azure
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
@@ -45,6 +45,7 @@ To have a proper and secure environment, we need these components:
|
|
|
45
45
|
* Storage account for media and static files
|
|
46
46
|
* CDN endpoint in front with a domain name of our choosing
|
|
47
47
|
* PostgreSQL server
|
|
48
|
+
* Azure Communication Services to send e-mails
|
|
48
49
|
* Webapp with multiple custom host names and managed SSL for the website itself
|
|
49
50
|
* Webapp running pgAdmin
|
|
50
51
|
|
|
@@ -101,6 +102,8 @@ django.add_django_website(
|
|
|
101
102
|
repository_branch="main",
|
|
102
103
|
website_hosts=["example.com", "www.example.com"],
|
|
103
104
|
django_settings_module="mywebsite.settings.production",
|
|
105
|
+
comms_data_location="europe",
|
|
106
|
+
comms_domains=["mydomain.com"],
|
|
104
107
|
)
|
|
105
108
|
|
|
106
109
|
django.add_database_administrator(
|
|
@@ -120,6 +123,7 @@ django.add_database_administrator(
|
|
|
120
123
|
6. Re-deploy with custom hosts
|
|
121
124
|
7. Re-deploy once more to enable HTTPS on website domains
|
|
122
125
|
8. Manually activate HTTPS on the CDN host
|
|
126
|
+
9. Go to the e-mail communications service on Azure and configure DKIM, SPF,... for your custom domains.
|
|
123
127
|
|
|
124
128
|
## Custom domain name for CDN
|
|
125
129
|
When deploying the first time, you will get a `cdn_cname` output. You need to create a CNAME to this domain before the deployment of the custom domain will succeed.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pulumi-django-azure-1.0.4 → pulumi-django-azure-1.0.7}/src/pulumi_django_azure.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|