Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Getting error "can't find external program "python3" #130

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

Closed
hasakura12 opened this issue Mar 11, 2021 · 3 comments
Closed

Getting error "can't find external program "python3" #130

hasakura12 opened this issue Mar 11, 2021 · 3 comments

Comments

@hasakura12
Copy link

Description

It worked fine the last time on March 3 2021.

Today when I ran terraform plan, I started getting

Error: can't find external program "python3"

I copied the latest .tf files to my local modules and tried terraform plan again but the same.

The error is probably from package.py

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Terraform: 0.13.0
  • Provider(s): aws >= 2.49
  • Module: ">= 0.12.28"

Reproduction

Steps to reproduce the behavior:
Are you using workspaces?
No

Have you cleared the local cache (see Notice section above)?
Yes

List steps in order that led up to the issue you encountered

  1. Using CloudWatch Event to trigger lambda, following this example: https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/examples/triggers/main.tf

Code Snippet to Reproduce

# CloudWatch rule to schedule Lambda to run acceptance tests
# https://aws.amazon.com/blogs/aws/ec2-run-command-is-now-a-cloudwatch-events-target/
module "cloudwatch_event_rule" {
  source = "../../resource_module/monitoring/cloudwatch_rule"

  ## CloudWatch Event Rule ##
  cloudwatch_rule_name        = var.cloudwatch_rule_name_lambda_acceptance_tests
  cloudwatch_rule_description = var.cloudwatch_rule_description_lambda_acceptance_tests
  schedule_expression         = var.cloudwatch_rule_schedule_expression_lambda_acceptance_tests

  ## CloudWatch Event Target ##
  is_target_ssm_run_command = false
  cloudwatch_event_target_arn = module.lambda_function_container_image_acceptance_tests.this_lambda_function_arn
}

resource "random_id" "this" {
  byte_length = 2
}

# ref: https://github.com/terraform-aws-modules/terraform-aws-lambda
module "lambda_function_container_image_acceptance_tests" {
  source = "../../resource_module/compute/lambda"

  function_name = local.lambda_function_name
  description   = local.lambda_function_description
  create_package = local.lambda_create_package
  image_uri    = "${local.ecr_address}/${local.ecr_lambda_acceptance_tests_name}:${var.acceptance_tests_image_tag}" # or "${module.ecr.repository_url}:latest" # "132367819851.dkr.ecr.eu-west-1.amazonaws.com/complete-cow:1.0" 
  package_type = local.lambda_package_type

  # need to add resource-based policy for lambda to allow CW Event to invoke it: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission
  # Refs: https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/examples/event-source-mapping/main.tf#L45-L58
  allowed_triggers = {
    cloudwatchevent = {
      principal  = "events.amazonaws.com"
      source_arn = module.cloudwatch_event_rule.arn
    }
  }

  # Error: Error adding new Lambda Permission for lambda: InvalidParameterValueException: We currently do not support adding policies for $LATEST.
  create_current_version_allowed_triggers = false

  timeout = var.lambda_timeout
  cloudwatch_logs_retention_in_days = var.cloudwatch_logs_retention_in_days

  # for running Lambda in VPC subnet (hitting Jenkins endpoint requires private network connection). Ref: https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/examples/with-vpc/main.tf#L26-L28
  vpc_subnet_ids         = var.vpc_subnet_ids
  vpc_security_group_ids = var.vpc_security_group_ids
  attach_network_policy  = true

  # SNS notifications Ref: https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/examples/async/main.tf#L25-L32
  create_async_event_config = true
  attach_async_event_policy = true
  destination_on_failure = module.sns_topic.this_sns_topic_arn # Ref: https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/
}

module "ecr" {
  source = "../../resource_module/container/ecr"

  ## ECR repo ##
  name                 = local.ecr_lambda_acceptance_tests_name
  image_tag_mutability = var.ecr_image_tag_mutability
  tags                 = local.ecr_lambda_acceptance_tests_tags

  ## ECR repo policy ##
  ecr_repo_policy = var.ecr_repo_policy

  ## ECR lifecycle policy ##
  ecr_lifecycle_policy = var.ecr_lifecycle_policy
}

###############################################
# SNS notifications
###############################################
module "sns_topic" {
  source = "../../resource_module/messaging/sns"

  name = "lambda-acceptance-tests-failures"

  tags = local.sns_topic_tags
}

Search result of python3 in the entire project:
Screen Shot 2021-03-12 at 3 29 55 AM

Expected behavior

terraform plan should not error out

Actual behavior

terraform plan does error out

Terminal Output Screenshot(s)

Additional context

@antonbabenko
Copy link
Member

The error you see is related to your local python installation which has changed since the last time you run this code.

Make sure that you have python3 in PATH (verify which python3).

@hasakura12
Copy link
Author

Worked thx!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants