当前位置: 首页 > news >正文

aws console 使用fargate部署aws服务快速跳转前端搜索栏

测试过程中需要在大量资源之间跳转,频繁的点击不如直接搜索来的快,于是写了一个搜索框方便跳转。

前端的静态页面可以通过s3静态网站托管实现,但是由于中国区需要备案的原因,可以使用ecs fargate部署

步骤如下:

  • 编写前端页面,打包镜像
  • 使用任务定义创建ecs fargate服务

编写页面和打包镜像

编写页面

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>ToImage</title><style>* {margin: 0;padding: 0;}.container {height: 300px;width: 100%;margin: 100px auto 0 auto;}.parent {position: relative;top: 50%;left: 30%;}.search1 {width: 650px;height: 50px;border-radius: 18px;outline: none;border: 1px solid #ccc;padding-left: 20px;padding-right: 100px;position: absolute;font-size: 20px;}.search2 {width: 650px;height: 50px;border-radius: 18px;outline: none;border: 1px solid #ccc;padding-left: 20px;padding-right: 100px;position: absolute;top: 60px;font-size: 20px;}.btn {height: 36px;width: 100px;position: absolute;background: #fff;top: 120px;left: 300px;border: none;outline: none;font-size: 20px;}</style>
</head><body><div class="container"><form id="awsform" class="parent" method="get" ><input id="servicename" type="text" class="search1" placeholder="Please Input ServiceName..." name="servicename" /><input id="serviceid" type="text" class="search2" placeholder="Please Input ServiceID..." name="serviceid" /><input type="button" class="btn" value="Search" onclick="jssubmit()"/></form></div><script type="text/javascript">function jssubmit() {var formdom = document.getElementById('awsform');var servicename = document.getElementById("servicename").valuevar serviceid = document.getElementById("serviceid").valueconsole.log(serviceid)switch(servicename){case "role":window.location.href = "https://cn-north-1.console.amazonaws.cn/iamv2/home?region=cn-north-1#/roles/details/" + serviceid; break;case "user":window.location.href = "https://cn-north-1.console.amazonaws.cn/iamv2/home?region=cn-north-1#/users/details/" + serviceid; break;case "ec2":window.location.href = "https://cn-north-1.console.amazonaws.cn/ec2/v2/home?region=cn-north-1#InstanceDetails:instanceId=" + serviceid; break;case "eni":window.location.href = "https://cn-north-1.console.amazonaws.cn/ec2/v2/home?region=cn-north-1#NetworkInterface:networkInterfaceId" + serviceid; break;case "sg":window.location.href = "https://cn-north-1.console.amazonaws.cn/ec2/v2/home?region=cn-north-1#SecurityGroup:groupId=" + serviceid; break;case "ebs":window.location.href = "https://cn-north-1.console.amazonaws.cn/ec2/v2/home?region=cn-north-1#VolumeDetails:volumeId=" + serviceid; break;case "vpc":window.location.href = "https://cn-north-1.console.amazonaws.cn/ec2/v2/home?region=cn-north-1#VolumeDetails:volumeId=" + serviceid; break;case "subnet":window.location.href = "https://cn-north-1.console.amazonaws.cn/vpc/home?region=cn-north-1#SubnetDetails:subnetId=" + serviceid; break;case "s3":window.location.href = "https://cn-north-1.console.amazonaws.cn/s3/buckets/" + serviceid ; break;case "eks":window.location.href = "https://cn-north-1.console.amazonaws.cn/eks/home?region=cn-north-1#/clusters/" + serviceid ; break;}return false}</script>
</body></html>

本地测试

docker run -it --rm -p 8000:80 -v /home/ec2-user/index.html:/usr/share/nginx/html/index.html  nginx:alpine-slim

修改端口为8090

// default.conf
server {listen       8090;server_name  localhost;#access_log  /var/log/nginx/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
}

打包镜像

FROM nginx:alpine-slim
COPY ./index.html /usr/share/nginx/html/index.html
COPY ./default.conf /etc/nginx/conf.d/default.conf

创建服务

在这里插入图片描述

访问跳转

在这里插入图片描述

http://www.lryc.cn/news/21131.html

相关文章:

  • Redis实战之Redisson使用技巧详解
  • SQLAlchemy
  • 【Linux学习笔记】8.Linux yum 命令和apt 命令
  • windows服务器实用(4)——使用IIS部署网站
  • Random(二)什么是伪共享?@sun.misc.Contended注解
  • Linux解压压缩
  • JavaSe第3次笔记
  • 非人工智能专业怎样从零开始学人工智能?
  • MyBatis之增、删、查、改
  • 死磕Spring,什么是SPI机制,对SpringBoot自动装配有什么帮助
  • 因果推断10--一种大规模预算约束因果森林算法(LBCF)
  • Linux基础命令-df显示磁盘的使用情况
  • 如何使用goquery进行HTML解析以及它的源码分析和实现原理
  • 【Java 数组和集合 区别及使用案例】
  • 使用pynimate制作动态排序图
  • Mysql 事务的隔离性(隔离级别)
  • 2023年网络安全竞赛——Python渗透测试PortScan.py
  • 【数据结构】栈的接口实现(附图解和源码)
  • LC-1255. 得分最高的单词集合(回溯)
  • 从中国文化看面试挑人标准
  • 谦卑对象设计模式
  • QML Animation动画详解
  • C#开发的OpenRA的加载界面边框的细节
  • 计算机网络笔记、面试八股(四)—— TCP连接
  • Centos7 安装jenkins java1.8版本
  • 【每日阅读】JS知识(三)
  • Vue(6)
  • Neo4j列表函数
  • 55. 跳跃游戏
  • typedef在c语言中的作用