You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Stackattack provides a curated collection of high-level infrastructure components built on top of Pulumi. It allows you to deploy your applications on robust, secure infrastructure without giving up any control or spending days putting it together. Components are just functions, making them copy-paste friendly, so you can choose to use Stackattack as a library or just a set of working examples that you can take and modify for your own purposes.
_NOTE_: While this example is meant to demonstrate how much you can do with Stackattack with a small amount of code, it is not recommended to structure your infrastructure code this way with everying in a single stack. See the [Structuring Stacks](https://stackattack.camfeenstra.com/working-with-pulumi/structuring-stacks/) section for recommendations on how separating your resources into stacks.
45
45
46
-
## Key Features
46
+
## Features
47
47
48
48
-**Secure by Default** - All components are designed with secure defaults in mind, allowing you to get started quickly without worrying about security debt
49
49
-**Copy/Paste Friendly** - Components are just functions, no heavy abstractions--you can copy/paste and modify them to fit your use-case. It's always easiest to start with something that works!
Copy file name to clipboardExpand all lines: packages/aws/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,6 @@
2
2
3
3
Stackattack provides a curated collection of high-level infrastructure components built on top of Pulumi. It allows you to deploy your applications on robust, secure infrastructure without giving up any control or spending days putting it together. Components are just functions, making them copy-paste friendly, so you can choose to use Stackattack as a library or just a set of working examples that you can take and modify for your own purposes.
Copy file name to clipboardExpand all lines: packages/aws/src/components/cluster.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
/**
2
2
* @packageDocumentation
3
3
*
4
-
* ECS clusters in AWS provide compute capacity for running containerized applications. Stackattack creates ECS clusters with:
4
+
* ECS clusters in AWS provide compute capacity for running containerized applications. Stackattack's `cluster` component provides an easy way to set up working ECS clusters for running applications on EC2 instances with auto-scaling and private inter-service communication.
5
+
*
6
+
* Stackattack creates ECS clusters with:
5
7
* - EC2 instances used for compute. By default, the configuration will use spot instances. Pass `noSpot: true` to disable spot instances, or `onDemandPercentage` with a percentage value to split your EC2 instances between on demand and spot. The number of instances will always match the requirements of your cluster (within the constraints you set via `minSize` (default 0) and `maxSize` (default 1)). Currently Fargate is not supported.
6
8
* - A private DNS namespace is created so that your services can communicate internally via ECS service discovery. ECS service connect is currently not supported.
/** Method to get a `Network`, which is a VPC and a set of subnets. `type` should be "public" to choose public subnet IDs, and "private" to choose private ones. You can optionally pass a number of `azs` to limit the number of availability zones that you want to include subnets from */
* - **Tags** - Common tags applied to all resources
10
+
* - **Hierarchical organization** - Ability to create nested contexts for different parts of your infrastructure
11
+
*
12
+
* The reasoning for having a context is quite simple: it allows you to abstract groups of components into functions without name collisions. For example, without a context, if you write a function like the following:
13
+
* ```typescript
14
+
* import * as aws from '@pulumi/aws';
15
+
* import * as pulumi from '@pulumi/pulumi';
16
+
*
17
+
* interface DnsRecordArgs {
18
+
* name: pulumi.Input<string>;
19
+
* zoneId: pulumi.Input<string>;
20
+
* ip: pulumi.Input<string>;
21
+
* }
22
+
*
23
+
* function dnsRecord({ name, zoneId, ip }: DnsRecordArgs) {
24
+
* return new aws.route53.Record("record", {
25
+
* name,
26
+
* zoneId,
27
+
* type: "A",
28
+
* ttl: 300,
29
+
* records: [ip]
30
+
* });
31
+
* }
32
+
* ```
33
+
* It will not work to use it multiple times in a single stack, for example:
* This code will fail when you run `pulumi up`, because you end up with two `aws.route53.Record` resources with the name "record". You can mitigate this by, for example, passing a prefix to `dnsRecord`, but stackattack's `context` provides a simple, clean way to do this in a consistent manner.
43
+
*
44
+
* ## Creating a Context
45
+
*
46
+
* For typical usage, you should simply instantiate a context without any arguments:
47
+
*
48
+
* ```typescript
49
+
* import * as saws from "@stackattack/aws";
50
+
*
51
+
* const ctx = saws.context();
52
+
* ```
53
+
* By default, this context will generate a prefix and default tags based on your project and stack name. This approach works well because your resources will be clearly distinguishable by name in the AWS console, and the tags will make it easy to distinguish what stack and project resources belong to.
54
+
*
55
+
* If you have more specific needs, you can create a context with a custom prefix and/or tags:
56
+
*
57
+
* ```typescript
58
+
* const ctx = saws.context({
59
+
* prefix: "my-app",
60
+
* tags: {
61
+
* Environment: "production",
62
+
* Team: "platform",
63
+
* Project: "web-service"
64
+
* }
65
+
* });
66
+
* ```
67
+
*
68
+
* ## Using Contexts
69
+
*
70
+
* Every Stackattack component takes a Context as its first parameter:
71
+
*
72
+
* ```typescript
73
+
* const storage = saws.bucket(ctx, {
74
+
* versioned: true,
75
+
* });
76
+
*
77
+
* const vpc = saws.vpc(ctx);
78
+
* ```
79
+
*
80
+
* You can create nested contexts for different parts of your infrastructure:
81
+
*
82
+
* ```typescript
83
+
* const ctx = saws.context();
84
+
*
85
+
* // Each will have appropriate naming: my-app-storage-*, my-app-database-*
* _NOTE_: all Stackattack components add default prefixes to the context you pass in by default, so it's never _necessary_ to use `.prefix` unless you're creating multiple instances of a single component with the same context. All components also take `noPrefix: true` to disable to default prefixing behavior.
91
+
*
92
+
* ## Adding Tags
93
+
*
94
+
* You can add additional tags to a context:
95
+
*
96
+
* ```typescript
97
+
* const baseCtx = saws.context();
98
+
*
99
+
* const prodCtx = baseCtx.withTags({
100
+
* Environment: "production",
101
+
* CostCenter: "engineering"
102
+
* });
103
+
* ```
104
+
*/
2
105
import*aspulumifrom"@pulumi/pulumi";
3
106
4
107
/**
@@ -7,8 +110,6 @@ import * as pulumi from "@pulumi/pulumi";
7
110
exportinterfaceContext{
8
111
/** Generates a resource ID by combining the context prefix with an optional value */
9
112
id: (value?: string)=>string;
10
-
/** Generates a short ID with a hash suffix for uniqueness */
/** Creates a new Context with an extended prefix */
@@ -21,13 +122,25 @@ export interface Context {
21
122
* Configuration options for creating a Context.
22
123
*/
23
124
exportinterfaceContextOpts{
24
-
/** Optional prefix for resource naming (defaults to project-stack combination) */
125
+
/** Optional prefix for resource naming (defaults to project-stack combination). Defaults to `<project>-<stack>`, unless `stack` begins with `project` (e.g. project is named `api` and stack is named `api-prod`), in which case the default will just be `stack` */
25
126
prefix?: string|null;
26
-
/** Optional tags to apply to all resources created with this context */
127
+
/** Optional tags to apply to all resources created with this context. Defaults to `{ Source: "pulumi", Project: <project>, Stack: <stack> }` */
27
128
tags?: Record<string,string>;
28
129
}
29
130
30
-
functiondefaultContextPrefix(): string{
131
+
/** Generates a default set of context tags based on the current project and stack, plus a `Source: "pulumi"` tag. */
/** Generates a default prefix based on the current project and stack. Defaults to `<project>-<stack>`, unless `stack` begins with `project` (e.g. project is named `api` and stack is named `api-prod`), in which case the default will just be `stack` */
Copy file name to clipboardExpand all lines: packages/aws/src/select.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@
58
58
* pulumi up
59
59
* ```
60
60
*
61
-
* This pattern enables you to deploy shared infrastructure separately from applications, allowing for faster deployments and better isolation. See the [Structuring Stacks](/working-with-pulumi/structuring-stacks) guide for recommendations on separating your resources into stacks.
61
+
* This pattern enables you to deploy shared infrastructure separately from applications, allowing for faster deployments and better isolation. See the [Structuring Stacks](/working-with-pulumi/structuring-stacks/) guide for recommendations on separating your resources into stacks.
Copy file name to clipboardExpand all lines: packages/aws/src/stack-ref.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@
55
55
* pulumi up
56
56
* ```
57
57
*
58
-
* The function parameter serves as a type template - it defines the shape of the referenced stack's outputs without being executed. This enables full TypeScript IntelliSense and type checking for cross-stack references. See the [Structuring Stacks](/working-with-pulumi/structuring-stacks) guide for comprehensive multi-stack patterns.
58
+
* The function parameter serves as a type template - it defines the shape of the referenced stack's outputs without being executed. This enables full TypeScript IntelliSense and type checking for cross-stack references. See the [Structuring Stacks](/working-with-pulumi/structuring-stacks/) guide for comprehensive multi-stack patterns.
0 commit comments