Skip to content

Commit ada69ae

Browse files
committed
feat: adding support for ssl on cdn endpoints
1 parent 235d884 commit ada69ae

28 files changed

+3271
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ p-examples/
4848
.mono
4949
go.work*
5050
*.sln
51+
52+
**/.claude/settings.local.json

CLAUDE.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
This repository contains the Pulumi Azure Native provider, which enables Pulumi users to manage Azure resources using TypeScript, Python, Go, .NET, and Java. The provider directly calls the Azure Resource Manager (ARM) REST API, providing comprehensive coverage of Azure services.
8+
9+
## Build and Development Commands
10+
11+
### Setup and Dependencies
12+
13+
- **Dependencies**:
14+
- Go 1.21+
15+
- NodeJS 18.X.X+
16+
- Python 3.10+
17+
- .NET 6+
18+
- Gradle 8+
19+
20+
### Core Build Commands
21+
22+
```bash
23+
# Full build (generate schema, SDKs, and build the provider)
24+
make
25+
26+
# Generate schema only
27+
make schema
28+
29+
# Regenerate schema and update docs
30+
make generate_schema generate_docs
31+
32+
# Generate SDKs for all languages
33+
make generate
34+
35+
# Build the provider binary
36+
make provider
37+
38+
# Install the provider locally (used for testing)
39+
make install_provider
40+
41+
# Clean the build
42+
make clean
43+
```
44+
45+
### SDK Generation and Building
46+
47+
```bash
48+
# Generate SDKs for specific languages
49+
make generate_java
50+
make generate_nodejs
51+
make generate_python
52+
make generate_dotnet
53+
make generate_go
54+
55+
# Build SDKs for specific languages
56+
make build_nodejs
57+
make build_python
58+
make build_dotnet
59+
make build_java
60+
make build_go
61+
```
62+
63+
### Testing
64+
65+
```bash
66+
# Run all tests
67+
make test
68+
69+
# Run tests for specific languages
70+
make test_dotnet
71+
make test_python
72+
make test_go
73+
make test_nodejs
74+
75+
# Run provider tests
76+
make test_provider
77+
78+
# Run specific test by name
79+
make test TEST_NAME=TestXXX
80+
81+
# Run specific test category
82+
make test TEST_TAGS=nodejs
83+
```
84+
85+
### Schema Management
86+
87+
```bash
88+
# Generate schema squeeze (for major version releases)
89+
make schema_squeeze
90+
```
91+
92+
## Code Architecture
93+
94+
### Key Components
95+
96+
1. **Azure Specifications**: The repository uses Azure's REST API specifications from the `azure-rest-api-specs` submodule.
97+
98+
2. **Provider**: The core provider implementation is in `provider/pkg`, which handles:
99+
- Authentication with Azure
100+
- CRUD operations for resources
101+
- Type conversions between Pulumi and Azure
102+
- Handling of special cases and customizations
103+
104+
3. **Code Generator**: The `pulumi-gen-azure-native` tool generates schemas and SDKs based on Azure's OpenAPI specifications.
105+
106+
4. **SDKs**: Generated SDKs for multiple languages in the `sdk/` directory:
107+
- TypeScript/JavaScript (`sdk/nodejs`)
108+
- Python (`sdk/python`)
109+
- .NET (`sdk/dotnet`)
110+
- Go (`sdk/go`)
111+
- Java (`sdk/java`)
112+
113+
5. **Version Management**: The provider supports multiple API versions through configuration in the `versions/` directory:
114+
- Each major version has its own configuration
115+
- API versions are selectively included based on compatibility and features
116+
117+
### Important Subsystems
118+
119+
#### Sub-Resources
120+
121+
The provider handles "sub-resource properties" specially. These are resources that can be defined inline with a parent resource or as standalone resources. The provider ensures that:
122+
- On Create: Default values are set for unset sub-resource properties
123+
- On Update: Existing sub-resources are preserved during updates
124+
- On Read: Unset sub-resource properties are reset to empty values
125+
126+
#### Custom Resources
127+
128+
Some Azure resources require special handling beyond what can be generated from the OpenAPI specs. These custom implementations are in `provider/pkg/resources/customresources/`.
129+
130+
## Development Workflow
131+
132+
1. **Understanding API Versions**: Azure's REST API has many versions with ISO date format (e.g., `2020-01-01`).
133+
- Not all versions contain all resources
134+
- Preview versions (`-preview` suffix) are sometimes stable for everyday use
135+
- The provider selectively includes versions to maintain compatibility
136+
137+
2. **Making Changes**:
138+
- For schema changes, modify files in `versions/` directory
139+
- For provider behavior changes, modify files in `provider/pkg/`
140+
- For custom resource implementations, modify files in `provider/pkg/resources/customresources/`
141+
142+
3. **Testing Changes**:
143+
- Run unit tests with `make test_provider`
144+
- Test examples with `make test` or language-specific tests
145+
146+
4. **Adding Resource Documentation**:
147+
- Add documentation in `docs/resources/` folder
148+
- File naming follows the pattern: `[module]-[Resource].md` (e.g., `sql-Server.md`)
149+
- Regenerate docs with `make generate generate_docs`
150+
151+
## Common Issues and Solutions
152+
153+
1. **Schema Generation**: If schema generation fails, check that the Azure REST API specs submodule is properly initialized:
154+
```bash
155+
git submodule update --init --recursive
156+
```
157+
158+
2. **Sub-resource Handling**: When troubleshooting issues with resources that contain sub-resources, check the implementation in `provider/pkg/provider/`.
159+
160+
3. **Version Compatibility**: When adding support for new API versions, check for compatibility with existing versions in the `versions/` directory.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: cdn-custom-domain-https
2+
runtime: nodejs
3+
description: A Pulumi example demonstrating how to enable HTTPS on a CDN custom domain
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import * as pulumi from "@pulumi/pulumi";
2+
import * as resources from "@pulumi/azure-native/resources";
3+
import * as cdn from "@pulumi/azure-native/cdn";
4+
5+
// Create a resource group
6+
const resourceGroup = new resources.ResourceGroup("resourceGroup");
7+
8+
// Create a CDN profile
9+
const cdnProfile = new cdn.Profile("cdnProfile", {
10+
resourceGroupName: resourceGroup.name,
11+
location: resourceGroup.location,
12+
sku: {
13+
name: "Standard_Microsoft",
14+
},
15+
});
16+
17+
// Create a CDN endpoint
18+
const cdnEndpoint = new cdn.Endpoint("cdnEndpoint", {
19+
resourceGroupName: resourceGroup.name,
20+
profileName: cdnProfile.name,
21+
location: resourceGroup.location,
22+
originHostHeader: "www.contoso.com",
23+
origins: [{
24+
name: "contoso",
25+
hostName: "www.contoso.com",
26+
}],
27+
});
28+
29+
// Create a custom domain
30+
const customDomain = new cdn.CustomDomain("customDomain", {
31+
resourceGroupName: resourceGroup.name,
32+
profileName: cdnProfile.name,
33+
endpointName: cdnEndpoint.name,
34+
hostName: "cdn.contoso.com",
35+
});
36+
37+
// Enable HTTPS on the custom domain using CDN-managed certificate
38+
const customDomainHttps = new cdn.CustomDomainHttps("customDomainHttps", {
39+
resourceGroupName: resourceGroup.name,
40+
profileName: cdnProfile.name,
41+
endpointName: cdnEndpoint.name,
42+
customDomainName: customDomain.name,
43+
httpsEnabled: true,
44+
certificateSource: "Cdn",
45+
protocolType: "ServerNameIndication",
46+
certificateType: "Shared",
47+
minimumTlsVersion: "TLS12",
48+
});
49+
50+
// Export the custom domain name and HTTPS status
51+
export const customDomainName = customDomain.name;
52+
export const httpsEnabled = customDomainHttps.httpsEnabled;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "cdn-custom-domain-https",
3+
"devDependencies": {
4+
"@types/node": "^10.0.0"
5+
},
6+
"dependencies": {
7+
"@pulumi/pulumi": "^3.0.0",
8+
"@pulumi/azure-native": "^2.0.0"
9+
}
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "bin",
4+
"target": "es2016",
5+
"module": "commonjs",
6+
"moduleResolution": "node",
7+
"sourceMap": true,
8+
"experimentalDecorators": true,
9+
"pretty": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"noImplicitAny": true,
12+
"noImplicitReturns": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"strictNullChecks": true
15+
},
16+
"files": [
17+
"index.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)