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

Cannot create new streamalert install in 3.4.0 #1294

Closed
cdaniluk opened this issue Oct 5, 2020 · 4 comments
Closed

Cannot create new streamalert install in 3.4.0 #1294

cdaniluk opened this issue Oct 5, 2020 · 4 comments

Comments

@cdaniluk
Copy link

cdaniluk commented Oct 5, 2020

Description

Fresh install does not seem to work on 3.4.0

Steps to Reproduce

Can reproduce on both macOS and Linux.

Start with a new clone of 3.4.0 and a new AWS account.

Run python manage.py init.
When prompted to create initial TF resources, say yes. After completion, the following error occurs:

State path: terraform.tfstate
[INFO 2020-10-05 17:02:46,172 (streamalert_cli.terraform.handlers:87)]: Configuring Terraform Remote State
Traceback (most recent call last):
  File "manage.py", line 151, in <module>
    sys.exit(main())
  File "manage.py", line 147, in main
    return not cli_runner(options)
  File "/opt/streamalert/streamalert_cli/runner.py", line 69, in cli_runner
    result = cmds[args.command](args)
  File "/opt/streamalert/streamalert_cli/runner.py", line 124, in <lambda>
    command: lambda opts, cmd=cli_command: cmd.handler(opts, config)
  File "/opt/streamalert/streamalert_cli/terraform/handlers.py", line 88, in handler
    if not terraform_generate_handler(config=config, check_tf=False, check_creds=False):
  File "/opt/streamalert/streamalert_cli/terraform/generate.py", line 427, in terraform_generate_handler
    _copy_terraform_files(config)
  File "/opt/streamalert/streamalert_cli/terraform/generate.py", line 399, in _copy_terraform_files
    ignore=shutil.ignore_patterns('*.tf.json')  # TODO: remove this eventually
  File "/usr/lib64/python3.7/shutil.py", line 324, in copytree
    os.makedirs(dst)
  File "/usr/lib64/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/tmp/streamalert_build-98hs47_x'

It seems to be attempting to write to the directory it has already created. This causes the created tf state to become orphanned.

@chunyong-lin
Copy link
Contributor

Hi @cdaniluk , thanks for reporting this issue.
Interesting. I noticed another StreamAlert user also mentioned this issue. If you have testing environment ready, can you give a try with customized build directory? Let me how does it go.

python manage.py --build-directory /tmp/streamalert_build init

We will look into this issue as soon as we get time.

@ryandeivert
Copy link
Contributor

I think I have a fix for it - please standby

@cdaniluk
Copy link
Author

cdaniluk commented Oct 5, 2020

I didn't try manually specifying a build dir since you had a fix so quickly. I switched over to that branch and got past it fine. So, I think that's a good fix. Thanks!

ryandeivert added a commit that referenced this issue Oct 5, 2020
ryandeivert added a commit that referenced this issue Oct 5, 2020
* bumping version to 3.4.1

* adding fix for #1294 to only copy terraform files once during init (#1295)

* adding fix for #1294

* pylint
@ryandeivert
Copy link
Contributor

fixed with #1295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants