4.7 KiB
Terraform Template For Artifactory Enterprise
Note: This Terraform template is no longer maintained. Feel free to review this code for your own POC concepts, but we are not continuing to update it or add features. We do plan to revive this in the future with a better implementation.
Prerequisites:
- An AWS account
- Basic knowledge of AWS
- Predefined Keys
- Basic knowledge of Artifactory
- Learn about system requirements for Artifactory
- Learn more about Terraform AWS provider follow: https://www.terraform.io/docs/providers/aws/index.html
Steps to Deploy Artifactory Enterprise Using Terraform Template
-
Set your AWS account credentials by setting environment variables:
export AWS_ACCESS_KEY_ID="your_access_key" export AWS_SECRET_ACCESS_KEY="your_secret_key" export AWS_DEFAULT_REGION="aws_region"To learn more about Terraform aws provider follow there documentation. https://www.terraform.io/docs/providers/aws/index.html
-
Modify the default values in the
variables.tffile -
Pass the Artifactory Enterprise licenses as a string in the variables
artifactory_license_1-5.
For example: Change disk space to 500Gb:variable "volume_size" { description = "Disk size for each EC2 instances" default = 500 } -
Run the
terraform init -var 'key_name=myAwsKey'command. This will install the required plugin for the AWS provider. -
Run the
terraform plan -var 'key_name=myAwsKey'command. -
Run the
terraform apply -var 'key_name=myAwsKey'command to deploy Artifactory Enterprise cluster on AWSNote: it takes approximately 15 minutes to bring up the cluster.
-
You will receive ELB Url to access Artifactory. By default, this template starts only one node in the Artifactory cluster. It takes 7-10 minutes for Artifactory to start and to attach the instance to the ELB.The output can be viewed as:
Outputs: address = artifactory-elb-265664219.us-west-2.elb.amazonaws.com -
Access the Artifactory UI using ELB Url provided in outputs.
-
Scale your cluster using following command:
terraform apply -var 'key_name=myAwsKey' -var 'secondary_node_count=2'In this example we are scaling artifactory cluster to 2 nodes.Note: You can only scale nodes to number of artifactory licenses you have available for cluster.
-
SSH into Artifactory primary instance and type inactiveServerCleaner plugin in
'/var/opt/jfrog/artifactory/etc/plugins'directory. (Optional) To destroy the cluster, run the following commend:terraform destroy -var 'key_name=myAwsKey'
Note:
-
This template only supports Artifactory version 5.8.x and above.
-
Turn off daily backups. Read Documentation provided here.
Note: In this template as default S3 is default filestore and data is persisted in S3. If you keep daily backups on disk space (default 250Gb) will get occupied quickly.
-
Use an SSL Certificate with a valid wildcard to your artifactory as docker registry with subdomain method.
Steps to setup Artifactory as secure docker registry
Considering you have SSL certificate for *.jfrog.team
- Pass your SSL Certificate in variable
ssl_certificateas string - Pass your SSL Certificate Key in variable
ssl_certificate_keyas string - Set
certificate_domainasjfrog.team - Set
artifactory_server_nameasartifactoryif you want to access artifactory withhttps://artifactory.jfrog.team - Create DNS for example Route53 with entry
artifactory.jfrog.teampointing to ELB value provided as output in Terraform Stack. - Create DNS for example Route53 with entry
*.jfrog.team pointingto ELB value provided as output in Terraform Stack. - If you have virtual docker registry with name
docker-virtualin artifactory. You can access it viadocker-virtual.jfrog.teame.gdocker pull docker-virtual.jfrog.team/nginx
Steps to upgrade Artifactory Version
-
Change the value of
artifactory_versionfrom old version to new Artifactory version you want to deploy. for e.g.5.8.1to5.8.2. -
Run command
terraform apply -var 'key_name=myAwsKey' -var 'secondary_node_count=2' -ver 'artifactory_version=5.8.2'. You will see instances will get upgraded one by one. Depending on your cluster size it will take 20-30 minutes to update stack.
Use Artifactory as backend
To to store state as an artifact in a given repository of Artifactory, see https://www.terraform.io/docs/backends/types/artifactory.html