<!DOCTYPE html><html><head><title>
Slack Invitation Link - hrshmistry
</title><!-- Style to create button --><style>.SLK{background-color:white;border:3pxsolidblack;color:green;text-align:center;display:inline-block;font-size:80px;cursor:pointer;}</style></head><body><centerstyle="font-size:70px;color:red;font-family:'Courier New'">Hybrid Multi-Cloud</center><palign = "center"><imgsrc="https://s3hrsh.s3.ap-south-1.amazonaws.com/cloud.jpg"width="300"height="300"></p><centerstyle="font-size:40px;color:blue;font-family:'Courier New'">Your Personal Slack Invitation Link</center><!-- Adding link to the button on the onclick event --><center><buttonclass="SLK"onclick="window.location.href = 'https://join.slack.com/t/hybridmulti-cloud/shared_invite/zt-etnyk2vm-gngGCm2hnk1VbOPR9nGpnw';">
JOIN NOW
</button></center></body></html>
#Creating Variable for AMI Idvariable"ami_id"{type=stringdefault="ami-0447a12f28fddb066"}#Creating Variable for AMI Typevariable"ami_type"{type=stringdefault="t2.micro"}#Creating Variable for keyvariable"EC2_Key"{type=stringdefault="Task1Key"}
resource"aws_s3_bucket""S3"{bucket="autos-s3-bucket"acl="public-read"}#Putting Objects in S3 Bucketresource"aws_s3_bucket_object""S3_Object"{depends_on=[aws_s3_bucket.S3]bucket=aws_s3_bucket.S3.bucketkey="Cloud.JPG"source="D:/LW/Hybrid-Multi-Cloud/Terraform/tera/task/Cloud.JPG"acl="public-read"}
使用 S3 Bucket Origin 创建 CloutFront
locals{S3_Origin_Id=aws_s3_bucket.S3.id}resource"aws_cloudfront_distribution""CloudFront"{depends_on=[aws_s3_bucket_object.S3_Object]origin{domain_name=aws_s3_bucket.S3.bucket_regional_domain_nameorigin_id=aws_s3_bucket.S3.id# OR origin_id = local.S3_Origin_Id}enabled=trueis_ipv6_enabled=truecomment="S3 Web Distribution"default_cache_behavior{allowed_methods=["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]cached_methods=["GET","HEAD"]target_origin_id=aws_s3_bucket.S3.id# OR origin_id = local.S3_Origin_Idforwarded_values{query_string=falsecookies{forward="none"}}viewer_protocol_policy="allow-all"min_ttl=0default_ttl=3600max_ttl=86400}# Cache behavior with precedence 0ordered_cache_behavior{path_pattern="/content/immutable/*"allowed_methods=["GET","HEAD","OPTIONS"]cached_methods=["GET","HEAD","OPTIONS"]target_origin_id=aws_s3_bucket.S3.id# OR origin_id = local.S3_Origin_Idforwarded_values{query_string=falseheaders=["Origin"]cookies{forward="none"}}min_ttl=0default_ttl=86400max_ttl=31536000compress=trueviewer_protocol_policy="redirect-to-https"}# Cache behavior with precedence 1ordered_cache_behavior{path_pattern="/content/*"allowed_methods=["GET","HEAD","OPTIONS"]cached_methods=["GET","HEAD"]target_origin_id=aws_s3_bucket.S3.id# OR origin_id = local.S3_Origin_Idforwarded_values{query_string=falsecookies{forward="none"}}min_ttl=0default_ttl=3600max_ttl=86400compress=trueviewer_protocol_policy="redirect-to-https"}price_class="PriceClass_200"restrictions{geo_restriction{restriction_type="whitelist"locations=["IN"]}}tags={Name="CF Distribution"Environment="Production"}viewer_certificate{cloudfront_default_certificate=true}retain_on_delete=true}
修改 HTML 代码并在其中添加图片 URL。
resource"null_resource""CF_URL"{depends_on=[aws_cloudfront_distribution.CloudFront]connection{type="ssh"user="ec2-user"private_key=tls_private_key.tls_key.private_key_pemhost=aws_instance.autos.public_ip}provisioner"remote-exec"{inline=["echo '<p align = 'center'>'","echo '<img src='https://${aws_cloudfront_distribution.CloudFront.domain_name}/Cloud.JPG' width='100' height='100'>' | sudo tee -a /var/www/html/Slack.html","echo '</p>'"]}}