-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crosswalk for AWS Guides needs refresh for AWSX 2.x #10230
Comments
Some preliminary investigation. For this, I did a few things:
Then I searched this repo for references to For
|
Related: #10162 |
All right, I think I have a good sense now of what's needed to fix up the issues here. It boils down to this:
Related updates will need to be made in pulumi/templates and pulumi/examples as well. The full examples I'm using to make these updates is:
"use strict";
const pulumi = require("@pulumi/pulumi");
const aws = require("@pulumi/aws");
const awsx = require("@pulumi/awsx");
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});
const image = new awsx.ecr.Image("image", {
repositoryUrl: repo.url,
context: "./app",
platform: "linux/amd64",
});
const cluster = new aws.ecs.Cluster("cluster");
const lb = new awsx.lb.ApplicationLoadBalancer("lb");
const service = new awsx.ecs.FargateService("service", {
cluster: cluster.arn,
assignPublicIp: true,
taskDefinitionArgs: {
container: {
name: "my-service",
image: image.imageUri,
cpu: 128,
memory: 512,
essential: true,
portMappings: [{
containerPort: 80,
targetGroup: lb.defaultTargetGroup,
}],
},
},
});
exports.url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});
const image = new awsx.ecr.Image("image", {
repositoryUrl: repo.url,
context: "./app",
platform: "linux/amd64",
});
const cluster = new aws.ecs.Cluster("cluster");
const lb = new awsx.lb.ApplicationLoadBalancer("lb");
const service = new awsx.ecs.FargateService("service", {
cluster: cluster.arn,
assignPublicIp: true,
taskDefinitionArgs: {
container: {
name: "my-service",
image: image.imageUri,
cpu: 128,
memory: 512,
essential: true,
portMappings: [{
containerPort: 80,
targetGroup: lb.defaultTargetGroup,
}],
},
},
});
export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx
repository = awsx.ecr.Repository(
"repository",
awsx.ecr.RepositoryArgs(
force_delete=True
),
)
image = awsx.ecr.Image(
"image",
awsx.ecr.ImageArgs(
repository_url=repository.url, context="./app", platform="linux/amd64"
),
)
cluster = aws.ecs.Cluster("cluster")
lb = awsx.lb.ApplicationLoadBalancer("lb")
service = awsx.ecs.FargateService(
"service",
awsx.ecs.FargateServiceArgs(
cluster=cluster.arn,
assign_public_ip=True,
task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
name="my-service",
image=image.image_uri,
cpu=128,
memory=512,
essential=True,
port_mappings=[
awsx.ecs.TaskDefinitionPortMappingArgs(
container_port=80,
target_group=lb.default_target_group,
)
],
),
),
),
)
pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name)) package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs"
"github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr"
ecsx "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs"
"github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/lb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{
ForceDelete: pulumi.Bool(true),
})
if err != nil {
return err
}
image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{
RepositoryUrl: repository.Url,
Context: pulumi.String("./app"),
Platform: pulumi.StringPtr("linux/amd64"),
})
if err != nil {
return err
}
cluster, err := ecs.NewCluster(ctx, "cluster", nil)
if err != nil {
return err
}
lb, err := lb.NewApplicationLoadBalancer(ctx, "lb", nil)
if err != nil {
return err
}
_, err = ecsx.NewFargateService(ctx, "service", &ecsx.FargateServiceArgs{
Cluster: cluster.Arn,
AssignPublicIp: pulumi.Bool(true),
TaskDefinitionArgs: &ecsx.FargateServiceTaskDefinitionArgs{
Container: &ecsx.TaskDefinitionContainerDefinitionArgs{
Name: pulumi.String("app"),
Image: image.ImageUri,
Cpu: pulumi.Int(128),
Memory: pulumi.Int(512),
Essential: pulumi.Bool(true),
PortMappings: ecsx.TaskDefinitionPortMappingArray{
&ecsx.TaskDefinitionPortMappingArgs{
ContainerPort: pulumi.Int(80),
TargetGroup: lb.DefaultTargetGroup,
},
},
},
},
})
if err != nil {
return err
}
ctx.Export("url", pulumi.Sprintf("http://%s", lb.LoadBalancer.DnsName()))
return nil
})
} using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;
using Awsx = Pulumi.Awsx;
return await Deployment.RunAsync(() =>
{
var cluster = new Aws.Ecs.Cluster("cluster");
var repo = new Awsx.Ecr.Repository("repo", new()
{
ForceDelete = true,
});
var image = new Awsx.Ecr.Image("image", new()
{
RepositoryUrl = repo.Url,
Context = "./app",
Platform = "linux/amd64",
});
var lb = new Awsx.Lb.ApplicationLoadBalancer("lb");
var service = new Awsx.Ecs.FargateService("service", new Awsx.Ecs.FargateServiceArgs
{
Cluster = cluster.Arn,
AssignPublicIp = true,
TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs
{
Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs
{
Name = "my-service",
Image = image.ImageUri,
Cpu = 128,
Memory = 512,
Essential = true,
PortMappings = new[]
{
new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs
{
ContainerPort = 80,
TargetGroup = lb.DefaultTargetGroup,
},
},
},
},
});
return new Dictionary<string, object?>
{
["url"] = lb.LoadBalancer.Apply(loadBalancer => Output.Format($"http://{loadBalancer.DnsName}")),
};
}); package myproject;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.awsx.ecr.Repository;
import com.pulumi.awsx.ecr.RepositoryArgs;
import com.pulumi.awsx.ecr.Image;
import com.pulumi.awsx.ecr.ImageArgs;
import com.pulumi.aws.ecs.Cluster;
import com.pulumi.awsx.lb.ApplicationLoadBalancer;
import com.pulumi.awsx.ecs.FargateService;
import com.pulumi.awsx.ecs.FargateServiceArgs;
import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs;
import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs;
import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var repository = new Repository("repository", RepositoryArgs.builder()
.forceDelete(true)
.build());
var image = new Image("image", ImageArgs.builder()
.repositoryUrl(repository.url())
.context("./app")
.platform("linux/amd64")
.build());
var cluster = new Cluster("cluster");
var lb = new ApplicationLoadBalancer("lb");
var service = new FargateService("service", FargateServiceArgs.builder()
.cluster(cluster.arn())
.assignPublicIp(true)
.taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder()
.container(TaskDefinitionContainerDefinitionArgs.builder()
.name("my-service")
.image(image.imageUri())
.cpu(128)
.memory(512)
.essential(true)
.portMappings(TaskDefinitionPortMappingArgs.builder()
.containerPort(80)
.targetGroup(lb.defaultTargetGroup())
.build())
.build())
.build())
.build());
ctx.export("url", Output.format("http://%s", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())));
}
} ☝️ This example, however, will fail until pulumi/pulumi-awsx#820 is fixed. name: my-project
runtime: yaml
resources:
repo:
type: awsx:ecr:Repository
properties:
forceDelete: true
lb:
type: awsx:lb:ApplicationLoadBalancer
image:
type: awsx:ecr:Image
properties:
repositoryUrl: ${repo.url}
context: ./app
platform: linux/amd64
cluster:
type: aws:ecs:Cluster
service:
type: awsx:ecs:FargateService
properties:
cluster: ${cluster.arn}
assignPublicIp: true
taskDefinitionArgs:
container:
name: my-service
image: ${image.imageUri}
cpu: 128
memory: 512
essential: true
portMappings:
- containerPort: 80
targetGroup: ${lb.defaultTargetGroup}
outputs:
url: http://${lb.loadBalancer.dnsName} This provisions a load balancer that listens on port 80 and forwards to a container service that also listens on port 80. If the example forwards to a port other than 80, the |
Related to #11566 |
This is now complete, with the exception of the Kubernetes "apps" page, which has deeper issues. I'll file a follow-up for that one. |
Problem description
A community user brought up a product documentation issue on the following URL: https://www.pulumi.com/docs/clouds/aws/guides/
Specifically, the user was tripped up by the ECR example, which references parameters that are no longer supported in AWSX 2.x (like the
path
parameter, which is replaced bycontext
).This carries over into the more detailed ECR guide found at https://www.pulumi.com/docs/clouds/aws/guides/ecr/ as well.
Pretty much every
awsx.ecr.Image
example is wrong; I checked the ECR page, the EKS page, and the ECS page and found incorrect examples.Affected product version(s)
The docs reflect AWSX 1.x, but AWSX 2.x is the default/major version now in use.
Suggestions for a fix
Update all code examples that use
awsx.ecr.Image
to reflect correct usage with AWSX 2.x.The text was updated successfully, but these errors were encountered: