Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/scheduled-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ jobs:

- name: Install Pulumi
uses: pulumi/actions@v4
with:
pulumi-version: latest

- name: Check out the code
uses: actions/checkout@v3
Expand Down
11 changes: 9 additions & 2 deletions content/docs/iac/concepts/projects/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ When your Pulumi program refers to resources in the local filesystem, paths are

{{< example-program path="awsx-ecr-image" >}}

## Root-relative paths

You can get the directory containing the `Pulumi.yaml` file, which may differ from your working directory if it specified a `main` option (see [main attribute](/docs/reference/pulumi-yaml/#attributes)), with the `ProjectDirectory` function.

The path returned is an absolute path. When using this in resource properties, ensure it's relative to the working directory. This prevents diffs from running the project on multiple machines with different roots.

{{< example-program path="awsx-root-directory" >}}

## Getting the current project programmatically

The {{< pulumi-getproject >}} function returns the name of the currently deploying project. This can be useful for naming or tagging resources.
Expand Down Expand Up @@ -166,8 +174,7 @@ variables:
## Stack settings files {#stack-settings-file}

Each stack that is created in a project will have a file named `Pulumi.<stackname>.yaml` that contains the configuration specific to this stack. This file typically resides in the root of the project directory.
To change the location where stack configuration files are stored for a given project, set the `stackConfigDir` metadata attribute to a relative directory.

For stacks that are actively developed by multiple members of a team, the recommended practice is to check them into source control as a means of collaboration. Since secret values are encrypted, it is safe to check in these stack settings. When using ephemeral stacks, the stack settings are typically not checked into source control.

For detailed information about the structure and format of stack settings files, see the [Stack settings file reference](/docs/iac/concepts/projects/stack-settings-file/). For more information about configuration and how to manage these files on the command line and programmatically, refer to the [Configuration](/docs/concepts/config/) and [Secrets](/docs/concepts/secrets/) documentation.
For more information about configuration and how to manage these files on the command line and programmatically, refer to the [Configuration](/docs/concepts/config/) and [Secrets](/docs/concepts/secrets/) documentation.
29 changes: 29 additions & 0 deletions static/programs/awsx-root-directory-csharp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.IO;
using Pulumi;
using Awsx = Pulumi.Awsx;

return await Deployment.RunAsync(() =>
{
var root = Pulumi.Deployment.Instance.RootDirectory;
var cwd = Directory.GetCurrentDirectory();
var appPath = Path.Combine(root, "app");
var relativePath = Path.GetRelativePath(cwd, appPath);

var repository = new Awsx.Ecr.Repository("repository", new()
{
ForceDelete = true,
});

var image = new Awsx.Ecr.Image("image", new()
{
RepositoryUrl = repository.Url,
Context = relativePath,
Platform = "linux/amd64",
});

return new Dictionary<string, object?>
{
["url"] = repository.Url,
};
});
3 changes: 3 additions & 0 deletions static/programs/awsx-root-directory-csharp/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: awsx-root-directory-csharp
runtime:
name: dotnet
1 change: 1 addition & 0 deletions static/programs/awsx-root-directory-csharp/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi" Version="[3.87, 4.0.0)" />
<PackageReference Include="Pulumi.Aws" Version="6.*" />
<PackageReference Include="Pulumi.Awsx" Version="2.*" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions static/programs/awsx-root-directory-go/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-root-directory-go
runtime: go
1 change: 1 addition & 0 deletions static/programs/awsx-root-directory-go/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx
8 changes: 8 additions & 0 deletions static/programs/awsx-root-directory-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module awsx-root-directory-go

go 1.23.11

require (
github.com/pulumi/pulumi-awsx/sdk/v2 v2.13.0
github.com/pulumi/pulumi/sdk/v3 v3.153.0
)
43 changes: 43 additions & 0 deletions static/programs/awsx-root-directory-go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"os"
"path/filepath"

"github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
root := ctx.RootDirectory()
cwd, err := os.Getwd()
if err != nil {
return err
}
path := filepath.Join(root, "app")
path, err = filepath.Rel(cwd, path)
if err != nil {
return err
}

repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{
ForceDelete: pulumi.Bool(true),
})
if err != nil {
return err
}

_, err = ecr.NewImage(ctx, "image", &ecr.ImageArgs{
RepositoryUrl: repository.Url,
Context: pulumi.String(path),
Platform: pulumi.String("linux/amd64"),
})
if err != nil {
return err
}

ctx.Export("url", repository.Url)
return nil
})
}
5 changes: 5 additions & 0 deletions static/programs/awsx-root-directory-python/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: awsx-root-directory-python
runtime:
name: python
options:
virtualenv: venv
19 changes: 19 additions & 0 deletions static/programs/awsx-root-directory-python/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pulumi
import pulumi_awsx as awsx
import os

root = pulumi.get_root_directory()
cwd = os.getcwd()
app_path = os.path.join(root, "app")
relative_path = os.path.relpath(app_path, cwd)

repository = awsx.ecr.Repository("repository", force_delete=True)

image = awsx.ecr.Image(
"image",
repository_url=repository.url,
context=relative_path,
platform="linux/amd64",
)

pulumi.export("url", repository.url)
1 change: 1 addition & 0 deletions static/programs/awsx-root-directory-python/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx
3 changes: 3 additions & 0 deletions static/programs/awsx-root-directory-python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pulumi>=3.153.0,<4.0.0
pulumi-aws>=6.0.2,<7.0.0
pulumi-awsx>=2.0.0,<3.0.0
2 changes: 2 additions & 0 deletions static/programs/awsx-root-directory-typescript/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-root-directory-typescript
runtime: nodejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx
20 changes: 20 additions & 0 deletions static/programs/awsx-root-directory-typescript/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";
import { join, relative } from "path";

const root = pulumi.getRootDirectory();
const cwd = process.cwd();
const appPath = join(root, "app");
const relativePath = relative(cwd, appPath);

const repository = new awsx.ecr.Repository("repository", {
forceDelete: true,
});

const image = new awsx.ecr.Image("image", {
repositoryUrl: repository.url,
context: relativePath,
platform: "linux/amd64",
});

export const url = repository.url;
12 changes: 12 additions & 0 deletions static/programs/awsx-root-directory-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "repo-typescript",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18"
},
"dependencies": {
"@pulumi/pulumi": "^3.187.0",
"@pulumi/aws": "^6.0.0",
"@pulumi/awsx": "^2.0.0"
}
}
16 changes: 16 additions & 0 deletions static/programs/awsx-root-directory-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.ts"]
}
Loading