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

26 implement aws ssm connection type #31

Merged
merged 26 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e2bce47
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Nov 28, 2023
7b05f6d
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Dec 5, 2023
81cb271
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Dec 5, 2023
3c0d3b4
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Dec 5, 2023
7f88afd
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Dec 14, 2023
92bc821
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Dec 15, 2023
6c418eb
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 11, 2024
681999e
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 18, 2024
9de5484
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 19, 2024
6b05fe7
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 23, 2024
b4d8d3b
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 24, 2024
84a7b50
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 24, 2024
091eae3
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 24, 2024
0fdc56c
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 24, 2024
c5ea9a4
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 24, 2024
8669a9f
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 25, 2024
e41d5d6
Implement 'aws_ssm' connection type #26
dominik-przybyl-wttech Jan 25, 2024
96d905a
Default region + error handling
krystian-panek-vmltech Jan 26, 2024
c5dcc23
Defaults upgrade
krystian-panek-vmltech Jan 26, 2024
62500c7
Private fields
krystian-panek-vmltech Jan 26, 2024
8df5428
Minor imprs
krystian-panek-vmltech Jan 26, 2024
4340256
Deps upgrade
krystian-panek-vmltech Jan 26, 2024
2d1fbf5
Performance improvement
dominik-przybyl-wttech Jan 26, 2024
d4043d4
SSM works like a charm ;)
krystian-panek-vmltech Jan 29, 2024
9f3b271
Timeouts configurable
krystian-panek-vmltech Jan 29, 2024
5f60ea8
Done threshold
krystian-panek-vmltech Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ For example:
- `sh develop.sh examples/aws_ssh apply -auto-approve`
- `sh develop.sh examples/aws_ssh destroy -auto-approve`

- `sh develop.sh examples/aws_ssm plan`
- `sh develop.sh examples/aws_ssm apply -auto-approve`
- `sh develop.sh examples/aws_ssm destroy -auto-approve`

## Debugging the Provider

1. Run command `go run . -debug` from IDEA in debug mode and copy the value of `TF_REATTACH_PROVIDERS` from the output.
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Required:

Optional:

- `action_timeout` (String) Used when trying to connect to the AEM instance machine (often right after creating it). Need to be enough long because various types of connections (like AWS SSM or SSH) may need some time to boot up the agent.
- `credentials` (Map of String, Sensitive) Credentials for the connection type
- `state_timeout` (String) Used when reading the AEM instance state when determining the plan.


<a id="nestedblock--compose"></a>
Expand Down
36 changes: 35 additions & 1 deletion examples/aws_ssh/aem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ instance:
timeout: 10m
# Max time in which socket connection to instance should be established
reachable:
skip: false
timeout: 3s
# Bundle state tracking
bundle_stable:
skip: false
symbolic_names_ignored: []
# OSGi events tracking
event_stable:
skip: false
# Topics indicating that instance is not stable
topics_unstable:
- "org/osgi/framework/ServiceEvent/*"
Expand All @@ -91,16 +94,32 @@ instance:
- "org.osgi.service.component.runtime.ServiceComponentRuntime"
- "java.util.ResourceBundle"
received_max_age: 5s
# OSGi components state tracking
component_stable:
skip: false
pids:
include: ['com.day.crx.packaging.*', 'org.apache.sling.installer.*']
exclude: ['org.apache.sling.installer.hc.*', 'org.apache.sling.installer.core.impl.console.*']
match:
"disabled": []
"no config": []
"unsatisfied (reference)": []
"satisfied": []
# Sling Installer tracking
installer:
skip: false
# JMX state checking
state: true
# Pause Installation nodes checking
pause: true
# Specific endpoints / paths (like login page)
path_ready:
timeout: 10s

login_page:
skip: false
path: "/libs/granite/core/content/login.html"
status_code: 200
contained_text: QUICKSTART_HOMEPAGE

# Managed locally (set up automatically)
local:
Expand Down Expand Up @@ -138,6 +157,7 @@ instance:
package:
# Force re-uploading/installing of snapshot AEM packages (just built / unreleased)
snapshot_patterns: [ "**/*-SNAPSHOT.zip" ]
snapshot_ignored: false
# Use checksums to avoid re-deployments when snapshot AEM packages are unchanged
snapshot_deploy_skipping: true
# Disable following workflow launchers for a package deployment time only
Expand All @@ -151,6 +171,16 @@ instance:
console: false
# Fail on case 'installed with errors'
strict: true
# Number of changes after which the commit to the repository is performed
install_save_threshold: 1024
# Allows to relax dependency handling if needed
install_dependency_handling: required
# Controls how 'rep:policy' nodes are handled during import
install_ac_handling: ''

# 'SSL By Default'
ssl:
setup_timeout: 30s

# OSGi Framework
osgi:
Expand All @@ -166,6 +196,10 @@ instance:
crypto:
key_bundle_symbolic_name: com.adobe.granite.crypto.file

# Replication
replication:
bundle_symbolic_name: com.day.cq.cq-replication

# Workflow Manager
workflow:
launcher:
Expand Down
4 changes: 2 additions & 2 deletions examples/aws_ssh/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_iam_instance_profile" "aem_ec2" {
}

resource "aws_iam_role" "aem_ec2" {
name = "${local.workspace}_aem_ec2"
name = "${local.workspace}_aem_ec2"
assume_role_policy = trimspace(<<EOF
{
"Version": "2012-10-17",
Expand All @@ -49,7 +49,7 @@ resource "aws_iam_role" "aem_ec2" {
}
EOF
)
tags = local.tags
tags = local.tags
}

resource "aws_iam_role_policy_attachment" "s3" {
Expand Down
14 changes: 8 additions & 6 deletions examples/aws_ssm/aem.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ resource "aem_instance" "single" {
depends_on = [aws_instance.aem_single, aws_volume_attachment.aem_single_data]

client {
type = "aws_ssm"
type = "aws-ssm"
settings = {
instance_id = aws_instance.aem_single.id
region = "eu-central-1" // TODO infer from AWS provider config
}
}

Expand All @@ -17,21 +16,17 @@ resource "aem_instance" "single" {
"sudo mkfs -t ext4 ${local.aem_single_data_device}",
"sudo mkdir -p ${local.aem_single_data_dir}",
"sudo mount ${local.aem_single_data_device} ${local.aem_single_data_dir}",
"sudo chown -R ${local.ssh_user} ${local.aem_single_data_dir}",
"echo '${local.aem_single_data_device} ${local.aem_single_data_dir} ext4 defaults 0 0' | sudo tee -a /etc/fstab",
// installing AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
"sudo yum install -y unzip",
"curl 'https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o 'awscliv2.zip'",
"unzip -q awscliv2.zip",
"sudo ./aws/install --update",
// installing AWS SSM agent: https://docs.aws.amazon.com/systems-manager/latest/userguide/agent-install-rhel-8-9.html
"sudo dnf install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm",
]
}
}

compose {
config = file("aem.yml") // use templating here if needed: https://developer.hashicorp.com/terraform/language/functions/templatefile
create = {
inline = [
"mkdir -p '${local.aem_single_compose_dir}/aem/home/lib'",
Expand All @@ -40,6 +35,13 @@ resource "aem_instance" "single" {
"sh aemw instance create",
]
}
configure = {
inline = [
"sh aemw osgi config save --pid 'org.apache.sling.jcr.davex.impl.servlets.SlingDavExServlet' --input-string 'alias: /crx/server'",
"sh aemw repl agent setup -A --location 'author' --name 'publish' --input-string '{enabled: true, transportUri: \"http://localhost:4503/bin/receive?sling:authRequestLogin=1\", transportUser: admin, transportPassword: admin, userId: admin}'",
"sh aemw package deploy --file 'aem/home/lib/aem-service-pkg-6.5.*.0.zip'",
]
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions examples/aws_ssm/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ resource "aws_instance" "aem_single" {
instance_type = "m5.xlarge"
iam_instance_profile = aws_iam_instance_profile.aem_ec2.name
tags = local.tags
user_data = trimspace(<<EOF
#!/bin/bash
sudo dnf install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
EOF
)
}

resource "aws_ebs_volume" "aem_single_data" {
Expand All @@ -25,7 +30,7 @@ resource "aws_iam_instance_profile" "aem_ec2" {
}

resource "aws_iam_role" "aem_ec2" {
name = "${local.workspace}_aem_ec2"
name = "${local.workspace}_aem_ec2"
assume_role_policy = trimspace(<<EOF
{
"Version": "2012-10-17",
Expand All @@ -37,7 +42,7 @@ resource "aws_iam_role" "aem_ec2" {
}
EOF
)
tags = local.tags
tags = local.tags
}

resource "aws_iam_role_policy_attachment" "ssm" {
Expand Down
3 changes: 0 additions & 3 deletions examples/aws_ssm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ locals {
env_type = "aem-single"
host = "aem_single"

ssh_user = "ec2-user"
ssh_private_key = abspath("ec2-key.cer")

tags = {
Workspace = "aemc"
Env = "tf-minimal"
Expand Down
39 changes: 27 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ module github.com/wttech/terraform-provider-aem
go 1.19

require (
github.com/aws/aws-sdk-go-v2 v1.24.1
github.com/aws/aws-sdk-go-v2/config v1.26.6
github.com/aws/aws-sdk-go-v2/service/ssm v1.44.7
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-go v0.19.0
github.com/hashicorp/terraform-plugin-framework v1.5.0
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/melbahja/goph v1.4.0
github.com/spf13/cast v1.5.1
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
github.com/spf13/cast v1.6.0
golang.org/x/crypto v0.18.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -21,15 +24,26 @@ require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.16.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.26.7 // indirect
github.com/aws/smithy-go v1.19.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand All @@ -42,6 +56,7 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -59,10 +74,10 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/grpc v1.61.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
Loading
Loading