brief-car-60542
03/24/2023, 4:23 AMPulumi.<cluster>.yaml
And some yaml file with resource A, some yaml with resource B. Seems each resource will trying to build with all stack files.
Here is a example project structure I am going with:
├── infrastructure
│ ├── iac
│ │ ├── aws
│ │ │ ├── containers
│ │ │ │ ├── index.ts
│ │ │ │ ├── package.json
│ │ │ │ ├── Pulumi.yaml
│ │ │ │ ├── Pulumi.foo.yaml
│ │ │ │ ├── Pulumi.bar.yaml
│ │ │ │ ├── ecr
│ │ │ │ │ ├── index.ts
│ │ │ │ ├── fargate
│ │ │ │ │ ├── index.ts
Like a example here
Pulumi.foo.yaml
will only have ecr
resource.
Pulumi.bar.yaml
will only have fargate
resource.
How do I make each resource index.ts
smartly know if there is no config about ecr in the stack yaml file. I will do nothing.straight-fireman-55591
03/24/2023, 8:59 AMnice-pilot-2521
03/24/2023, 10:51 AMimport { Config } from "pulumi";
import { createSomeEcrResource } from "./ecr";
import { createSomeFargatResource } from "./fargate";
const ecrConfig = Config("ecr");
if (ecrConfig.getBoolean("enabled")) {
createSomeEcrResource(ecrConfig);
}
const fargateConfig = Config("fargate");
if (fargateConfig.getBoolean("enabled")) {
createSomeFargateResource(fargateConfig);
}
dry-journalist-60579
03/24/2023, 1:00 PMPulumi.*.yaml
correspond to separate Pulumi stacks of the same project?brief-car-60542
03/24/2023, 4:21 PMdry-journalist-60579
03/24/2023, 4:48 PMapplication
stack that has RDS, Amazon MQ, DNS, datadog, S3 buckets, SSM params, etc. and sets up the cluster… we have Pulumi.prod.yaml for the production site, Pulumi.staging.yaml for pre-prod, and Pulumi.dev.yaml for development…Pulumi.ci.yaml
pulumi.export("ecr-url", repository.url)
(python)brief-car-60542
03/24/2023, 4:54 PMPulumi.staging.yaml
have S3 bucket.
and Pulumi.dev.yaml
dont have any S3 bucket.
The S3 bucket index.ts file will try to load both yaml and needs to decide this file doesnt have S3 bucket config, and I will skip doing nothing.dry-journalist-60579
03/24/2023, 4:54 PMbuild_stack = pulumi.StackReference("our-org/builds/ci")
BUILDS_ECR_URL = build_stack.get_output("ecr-url")
brief-car-60542
03/24/2023, 4:56 PMdry-journalist-60579
03/24/2023, 4:57 PMif
statements are totally fine, and there are different approaches to the code designbrief-car-60542
03/24/2023, 4:58 PM├── infrastructure
│ ├── iac
│ │ ├── aws
│ │ │ ├── containers
│ │ │ │ ├── index.ts
│ │ │ │ ├── package.json
│ │ │ │ ├── Pulumi.yaml
│ │ │ │ ├── ecr
│ │ │ │ │ ├── index.ts
│ │ │ │ ├── fargate
│ │ │ │ │ ├── index.ts
│ │ │ ├── storage
│ │ │ │ ├── index.ts
│ │ │ │ ├── package.json
│ │ │ │ ├── Pulumi.yaml
│ │ │ │ ├── s3
│ │ │ │ │ ├── index.ts
Do you think I should do 1 project per resource or like what shown 1 project per categoryI was just checking to make sure that the different stacks within a single project weren't to set up different types of resources
If I have 1 project including many resource, I will have to do that right? with the structure I have above.dry-journalist-60579
03/24/2023, 5:26 PMcontainers
and storage
. To me, it doesn’t make sense for ecr
and fargate
to be separate “stacks” within the containers
projectecr
and fargate
are groups of resources that should live in the containers
project and when you want to launch those resources you should create a “stack” of the containers
projectcontainers/ecr/index.ts
and containers/fargate/index.ts
into the containers/index.ts
. For code organization, it’s nice to break it apart, and you can just use JS/TS importsbrief-car-60542
03/24/2023, 5:36 PMPulumi.dev.yaml
, this mean I want to have a dev cluster. and this cluster will have some resources such as ecr, fargate, s3.
And with my setup I will have 2 Pulumi.dev.yaml
file under storage
& containers
.
My questions will be should I keep ecr&fargate under same project of contaienrs or should I do this:
├── infrastructure
│ ├── iac
│ │ ├── aws
│ │ │ ├── containers
│ │ │ │ ├── ecr
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── package.json
│ │ │ │ │ ├── Pulumi.yaml
│ │ │ │ │ ├── index.ts
│ │ │ │ ├── fargate
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── package.json
│ │ │ │ │ ├── Pulumi.yaml
│ │ │ │ │ ├── index.ts
│ │ │ ├── storage
│ │ │ │ ├── s3
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── package.json
│ │ │ │ │ ├── Pulumi.yaml
│ │ │ │ │ ├── index.ts
dry-journalist-60579
03/24/2023, 5:50 PMFor now, Zephyr has decided to go with a monorepo approach—a single repository that contains both their application code and the Pulumi code to manage the infrastructure resources. All of the resources are defined in a single Pulumi project, with multiple stacks that correspond to development and production environments. Over the course of this series, we'll see how Zephyr's use of Pulumi changes as Zephyr grows and their application evolves.
brief-car-60542
03/24/2023, 5:54 PMdry-journalist-60579
03/24/2023, 5:55 PMbrief-car-60542
03/24/2023, 5:56 PMdry-journalist-60579
03/24/2023, 5:58 PMimport * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.Bucket("bucket", {
acl: "private",
tags: {
Environment: "Dev",
Name: "My bucket",
},
});
… I think it’s ok to repeat declarative code like this sometimess3/index.ts
?brief-car-60542
03/24/2023, 6:00 PMdry-journalist-60579
03/24/2023, 6:04 PMbrief-car-60542
03/24/2023, 6:07 PM