https://github.com/pulumi/pulumi-dotnet
.NET support for Pulumi
https://github.com/pulumi/pulumi-dotnet
Last synced: 2 months ago
JSON representation
.NET support for Pulumi
- Host: GitHub
- URL: https://github.com/pulumi/pulumi-dotnet
- Owner: pulumi
- License: apache-2.0
- Created: 2022-11-14T10:07:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-29T12:32:47.000Z (2 months ago)
- Last Synced: 2025-03-30T06:37:09.857Z (2 months ago)
- Language: C#
- Homepage:
- Size: 13.2 MB
- Stars: 29
- Watchers: 17
- Forks: 25
- Open Issues: 113
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# .NET Language Provider
A .NET language provider for Pulumi. Use your favorite .NET language to write Pulumi programs and deploy infrastructure to any cloud.
## Installing the [nuget](https://www.nuget.org/packages/Pulumi) package
```
dotnet add package Pulumi
```## Example Pulumi program with .NET and C#
Here's a simple example of a Pulumi app written in C# that creates some simple
AWS resources:```c#
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws.S3;return await Deployment.RunAsync(() =>
{
// Create the bucket, and make it public.
var bucket = new Bucket("media", new ()
{
Acl = "public-read"
});// Add some content.
var content = new BucketObject("basic-content", new ()
{
Acl = "public-read",
Bucket = bucket.Id,
ContentType = "text/plain; charset=utf8",
Key = "hello.txt",
Source = new StringAsset("Made with ❤, Pulumi, and .NET"),
});// Return some values that will become the Outputs of the stack.
return new Dictionary
{
["hello"] = "world",
["bucket-id"] = bucket.Id,
["content-id"] = content.Id,
["object-url"] = Output.Format($"http://{bucket.BucketDomainName}/{content.Key}"),
};
});
```Make a Pulumi.yaml file:
```
$ cat Pulumi.yamlname: hello-dotnet
runtime: dotnet
```Then, configure it:
```
$ pulumi stack init hello-dotnet
$ pulumi config set aws:region us-west-2
```And finally, `pulumi preview` and `pulumi up` as you would any other Pulumi project.
## Development and Testing
### Prerequisites
- Dotnet [SDK v6+](https://dotnet.microsoft.com/download/dotnet/6.0) installed on your machine.
- Go 1.24+ for building and testing `pulumi-language-dotnet`
- The Pulumi CLI (used in automation tests and for integration tests)Then you can run one of the following commands:
```bash
# Build the Pulumi SDK
dotnet run build-sdk# Running tests for the Pulumi SDK
dotnet run test-sdk# Running tests for the Pulumi Automation SDK
dotnet run test-automation-sdk# Install the language plugin
make install# Building the language plugin. A binary will be built into the pulumi-language-dotnet folder.
# this is the binary that will be used by the integration tests.
make build# Testing the language plugin
dotnet run test-language-plugin# Sync proto files from pulumi/pulumi
dotnet run sync-proto-files# List all integration tests
dotnet run list-integration-tests# Run a specific integration test
dotnet run integration test# Run all integration tests
dotnet run all-integration-tests# Format the code (or verify it's formatted correctly)
dotnet run format-sdk [verify]
```
# Running integration testsWhen running integration tests via an IDE like Goland or VSCode, you want the Pulumi CLI to use the `pulumi-language-dotnet` plugin from this repository, not the one that comes bundled with your Pulumi CLI. To do this, in your terminal `dotnet run build-language-plugin` or simply `cd pulumi-language-dotnet && go build`.
Alternatively, you can run `dotnet run integration test ` or `dotnet run all-integration-tests` which will build the language plugin for you just before running the tests.
## Public API Changes
When making changes to the code you may get the following compilation
error:```
error RS0016: Symbol XYZ' is not part of the declared API.
```This indicates a change in public API. If you are developing a change
and this is intentional, add the new API elements to
`PublicAPI.Shipped.txt` corresponding to your project (some IDEs
will do this automatically for you, but manual additions are fine as
well).