Skip to content
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

Run the ECS example, see error of https://logs.undefined.amazonaws.com/ preventing service up #1279

Open
zhangcheng opened this issue May 6, 2024 · 2 comments
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec service/ecs

Comments

@zhangcheng
Copy link

What happened?

I was trying the ECS example.

The container service won't start properly. I saw error as:

Task stopped at: 2024-05-06T11:20:53.694Z
ResourceInitializationError: failed to validate logger args: create stream has been retried 7 times: failed to create Cloudwatch log stream: RequestError: send request failed caused by: Post "https://logs.undefined.amazonaws.com/": dial tcp: lookup logs.undefined.amazonaws.com on 172.31.0.2:53: no such host : exit status 1

Clearly this part of https://logs.undefined.amazonaws.com/ isn't correct, since my region config is us-west-2 and all resources were created there.

Tried to explicitly specify region as AI suggested, didn't work.

aws_provider = aws.Provider("aws_provider", region="us-west-2")

Was using the latest pulumi-awsx==2.9.0 and pulumi-aws==6.33.1, downgraded to much earlier version, didn't work.

Unless I explicitly set log_group, as:

log_group = aws.cloudwatch.LogGroup("my-log-group")

# and this arg
log_configuration=awsx.ecs.TaskDefinitionLogConfigurationArgs(
    log_driver="awslogs",
    options={
        "awslogs-group": log_group.name,
        "awslogs-region": "us-west-2",  # Replace with your region
        "awslogs-stream-prefix": "ecs",
    },
),

This solved the issue finally.

Example

import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx

lb = awsx.lb.ApplicationLoadBalancer("lb")
cluster = aws.ecs.Cluster("cluster")

service = awsx.ecs.FargateService("service",
    cluster=cluster.arn,
    assign_public_ip=True,
    desired_count=2,
    task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
        container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
            name="my-service",
            image="nginx:latest",
            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))

Output of pulumi about

CLI
Version      3.115.1
Go Version   go1.22.2
Go Compiler  gc

Plugins
KIND      NAME    VERSION
language  python  unknown

Host
OS       darwin
Version  14.4.1
Arch     arm64

This project is written in python: executable='/Users/czhang/.asdf/shims/python3' version='3.11.8'

Current Stack: teng01/ecs/dev

TYPE                             URN
pulumi:pulumi:Stack              urn:pulumi:dev::ecs::pulumi:pulumi:Stack::ecs-dev
pulumi:providers:awsx            urn:pulumi:dev::ecs::pulumi:providers:awsx::default_2_7_0
pulumi:providers:aws             urn:pulumi:dev::ecs::pulumi:providers:aws::aws_provider
awsx:lb:ApplicationLoadBalancer  urn:pulumi:dev::ecs::awsx:lb:ApplicationLoadBalancer::lb
pulumi:providers:aws             urn:pulumi:dev::ecs::pulumi:providers:aws::default_6_0_4
aws:ecs/cluster:Cluster          urn:pulumi:dev::ecs::aws:ecs/cluster:Cluster::cluster


Found no pending operations associated with dev

Backend
Name           pulumi.com
URL            https://app.pulumi.com/teng01
User           teng01
Organizations  teng01
Token type     personal

Dependencies:
NAME        VERSION
pip         24.0
setuptools  65.5.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@zhangcheng zhangcheng added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 6, 2024
@t0yv0
Copy link
Member

t0yv0 commented May 7, 2024

Thanks so much for posting this! To clarify, in your final working example you are passing log_configuration to awsx.ecs.FargateServiceTaskDefinitionArgs to make this work ?

It appears that #1112 also brought up the logs.undefined.amazonaws.com error message so we have an opportunity to improve the provider by picking a better working default logging configuration so that the example works out of the box.

@t0yv0 t0yv0 added service/ecs impact/usability Something that impacts users' ability to use the product easily and intuitively and removed needs-triage Needs attention from the triage team labels May 7, 2024
@zhangcheng
Copy link
Author

Thanks so much for posting this! To clarify, in your final working example you are passing log_configuration to awsx.ecs.FargateServiceTaskDefinitionArgs to make this work ?

My final working example is:

task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
    container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
        name="my-service",
        image="nginx:latest",
        cpu=128,
        memory=512,
        essential=True,
        log_configuration=awsx.ecs.TaskDefinitionLogConfigurationArgs(
            log_driver="awslogs",
            options={
                "awslogs-group": log_group.name,
                "awslogs-region": "us-west-2",  # Replace with your region
                "awslogs-stream-prefix": "ecs",
            },
        ),
    ),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec service/ecs
Projects
None yet
Development

No branches or pull requests

2 participants