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

Container logging validation #1787

Closed
viraptor opened this issue Nov 18, 2020 · 3 comments
Closed

Container logging validation #1787

viraptor opened this issue Nov 18, 2020 · 3 comments
Labels
enhancement New feature or request v1 v1.X

Comments

@viraptor
Copy link

cfn-lint version: 0.41.0

Description of issue.

Lint request: validate container logging configuration.

I got an error when deploying:

2020-11-18 11:17:04 +1100 TaskDefinition AWS::ECS::TaskDefinition CREATE_FAILED
Invalid request provided: Create TaskDefinition:
Log driver awslogs requires options: awslogs-region, awslogs-group

It looks like this would have to be implemented as a specific check since it doesn't exist in the spec.

@PatMyron
Copy link
Contributor

Could you share the failing/working template snippet as well?

@viraptor
Copy link
Author

viraptor commented Nov 18, 2020

The resource itself - failing:

"TaskDefinition": {
  "Type": "AWS::ECS::TaskDefinition",
  "Properties": {
    "NetworkMode": "awsvpc",
    "ExecutionRoleArn": {
      "Fn::GetAtt": ["ExecutionRole", "Arn"]
    },
    "ContainerDefinitions": [
      {
        "Essential": true,
        "Image": {
          "Fn::Join": [
            "",
            [
              { "Ref": "AWS::AccountId" },
              ".dkr.ecr.",
              { "Ref": "AWS::Region" },
              ".amazonaws.com/",
              { "Ref": "ApplicationName" }
            ]
          ]
        },
        "Name": { "Ref": "ApplicationName" },
        "PortMappings": [
          {
            "ContainerPort": 4433,
            "Protocol": "tcp"
          }
        ],
        "LogConfiguration": {
          "LogDriver": "awslogs",
          "Options": {
          }
        }
      ]
    }
  }
}

Working:

"TaskDefinition": {
  "Type": "AWS::ECS::TaskDefinition",
  "Properties": {
    "NetworkMode": "awsvpc",
    "ExecutionRoleArn": {
      "Fn::GetAtt": [ "ExecutionRole", "Arn" ]
    },
    "ContainerDefinitions": [
      {
        "Essential": true,
        "Image": {
          "Fn::Join": [
            "",
            [
              { "Ref": "AWS::AccountId" },
              ".dkr.ecr.",
              { "Ref": "AWS::Region" },
              ".amazonaws.com/",
              { "Ref": "ApplicationName" }
            ]
          ]
        },
        "Name": { "Ref": "ApplicationName" },
        "PortMappings": [
          {
            "ContainerPort": 4433,
            "Protocol": "tcp"
          }
        ],
        "LogConfiguration": {
          "LogDriver": "awslogs",
          "Options": {
            "awslogs-group": "something",
            "awslogs-region": {
              "Ref": "AWS::Region"
            }
          }
        }
      ]
    }
  }
}

@kddejong
Copy link
Contributor

Added a rule for v1 that will validate the log configuration when using aws logs

@kddejong kddejong added the v1 v1.X label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1 v1.X
Projects
None yet
Development

No branches or pull requests

3 participants