From 46f37d406f029a0f5070575d0b335f46b98777fd Mon Sep 17 00:00:00 2001 From: pengtao Date: Sat, 8 May 2021 19:09:37 +0800 Subject: [PATCH] init --- .gitignore | 177 ++++++++++++++++++++++++++++++++++++++++ aliyun/ec2/terraform.tf | 41 ++++++++++ main.py | 16 ++++ 3 files changed, 234 insertions(+) create mode 100644 .gitignore create mode 100644 aliyun/ec2/terraform.tf create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..37d54ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,177 @@ +/aliyun/ec2/.terraform.lock.hcl +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### Terraform template +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Exclude all .tfvars files, which are likely to contain sentitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +# +*.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + diff --git a/aliyun/ec2/terraform.tf b/aliyun/ec2/terraform.tf new file mode 100644 index 0000000..2fc2af9 --- /dev/null +++ b/aliyun/ec2/terraform.tf @@ -0,0 +1,41 @@ +provider "alicloud" {} + +resource "alicloud_vpc" "vpc" { + vpc_name = "tf_test_foo" + cidr_block = "172.16.0.0/12" +} + +resource "alicloud_vswitch" "vsw" { + vpc_id = alicloud_vpc.vpc.id + cidr_block = "172.16.0.0/21" + zone_id = "cn-beijing-b" +} + +resource "alicloud_security_group" "default" { + name = "default" + vpc_id = alicloud_vpc.vpc.id +} + +resource "alicloud_instance" "instance" { + # cn-beijing + availability_zone = "cn-beijing-b" + security_groups = alicloud_security_group.default.*.id + # series III + instance_type = "ecs.n2.small" + system_disk_category = "cloud_efficiency" + image_id = "ubuntu_18_04_64_20G_alibase_20190624.vhd" + instance_name = "test_foo" + vswitch_id = alicloud_vswitch.vsw.id + internet_max_bandwidth_out = 10 +} + +resource "alicloud_security_group_rule" "allow_all_tcp" { + type = "ingress" + ip_protocol = "tcp" + nic_type = "intranet" + policy = "accept" + port_range = "1/65535" + priority = 1 + security_group_id = alicloud_security_group.default.id + cidr_ip = "0.0.0.0/0" +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..5b25c56 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +# 这是一个示例 Python 脚本。 + +# 按 ⌃R 执行或将其替换为您的代码。 +# 按 双击 ⇧ 在所有地方搜索类、文件、工具窗口、操作和设置。 + + +def print_hi(name): + # 在下面的代码行中使用断点来调试脚本。 + print(f'Hi, {name}') # 按 ⌘F8 切换断点。 + + +# 按间距中的绿色按钮以运行脚本。 +if __name__ == '__main__': + print_hi('PyCharm') + +# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助