鲜肉鲜肉永远不皱

文章 评论 浏览 29

鲜肉鲜肉永远不皱 2025-02-05 06:52:22

按照 @tonyn的评论的建议,我设法获得了 react-router 方法效果很好。

我重组 app.js 成为路由器的故乡,并将我的组件带入如下:

import React, { Component, Fragment } from 'react';
import ReactDOM from 'react-dom';
import UploadPage from './UploadPage';
import Viz from './Viz';
import { BrowserRouter as Router, Routes, Route, Link, Redirect } from 'react-router-dom'


export default class App extends Component {
  render() {
    return (
      <div>
        <Router>
            <Routes>
                <Route exact path='/' element={ <UploadPage />} />
                <Route exact path='/viz' element={ <Viz /> } />
            </Routes>
        </Router>
      </div>
    )
  }
}

ReactDOM.render(<App />, document.getElementById('app'))

这只给我留下了一个渲染。只有其他更新是Django方面的URL:

from django.urls import path
from . import views
urlpatterns = [
    path('', views.index),
    path('viz', views.index)
]

我现在更好地理解了这种互动,因此,感谢我指向正确的方向。

this 视频教程也为我带来了生命,所以我也会离开这里。

Following the advice from @TonyN's comments, I managed to get react-router method working well.

I reorganised App.js to be the home of the Router and brought my components in as follows:

import React, { Component, Fragment } from 'react';
import ReactDOM from 'react-dom';
import UploadPage from './UploadPage';
import Viz from './Viz';
import { BrowserRouter as Router, Routes, Route, Link, Redirect } from 'react-router-dom'


export default class App extends Component {
  render() {
    return (
      <div>
        <Router>
            <Routes>
                <Route exact path='/' element={ <UploadPage />} />
                <Route exact path='/viz' element={ <Viz /> } />
            </Routes>
        </Router>
      </div>
    )
  }
}

ReactDOM.render(<App />, document.getElementById('app'))

This left me with only one render. Only other update to make was urls on django side:

from django.urls import path
from . import views
urlpatterns = [
    path('', views.index),
    path('viz', views.index)
]

I now understand this interaction a bit better, so thanks for pointing me in the right direction.

This video tutorial also helped bring it to life for me, so I'll leave that here too.

为什么只有我在Django应用中的多页上只有第一个React组件渲染?

鲜肉鲜肉永远不皱 2025-02-04 19:08:35

我经历了这个问题。就我而言,该功能拼写错误。
如果功能的名称以大写字母开头,这确实很重要。
或者,如果所有字母都是相同的,例如原型的名称。
如果您使用具有自动语言完成的编辑器,则可以更容易。
就像代码一样,它可以支持更多的编程语言。

但是,不确定,由于getElementById的错误。
您只是看到,getElementById不起作用,这似乎是一个原因。
这只是我们可以看到的效果,错误可以在其他地方找到。
脚本在第一次遇到错误时停止,没有警告。

只需查看您上次更改的内容,请查看每条代码。
有时这不是那么明显,为什么出现某种错误。
如果什么都没有用,您也可以使用试用 /捕获错误检查。

善良的问候,阿德里安·布里纳斯(Adrian Brinas)

I had experienced this issue. In my case, the function was misspelled.
It does matter, if the name of a function starts with a capital letter.
Or if all the letters are the same, like in the name of the prototype.
If you use an editor with automatic language completion, can be easier.
Like should be Code, which could support more programming languages.

But it is not so sure, that the error it is because of getElementById.
You just see, getElementById doesn't work and this seems to be a cause.
This is just the effect we can see, the error could be found elsewhere.
And the script stops at the first encountered error without a warning.

Just see what you had changed last time, look at each line of code.
Sometimes it is not so obvious, why a certain kind of error appears.
If nothing could work, you can also use a try / catch error checking.

With kind regards, Adrian Brinas

getElementByid不起作用并返回null

鲜肉鲜肉永远不皱 2025-02-04 03:40:49

使用ATLAS群集的“ DNS SEED”格式来设置Eve的 mongo_uri ,如下所示:

MONGO_URI = "mongodb+srv://username:[email protected]/your_database?retryWrites=true&w=majority"

您应该在Atlas UI中找到群集的连接字符串。

有关更多信息,请参见连接字符串示例中的MongoDB Atlas部署:(

Using "DNS seed" format for an Atlas cluster to set eve's MONGO_URI like below works OK for me:

MONGO_URI = "mongodb+srv://username:[email protected]/your_database?retryWrites=true&w=majority"

You should find your cluster's connection string in Atlas UI.

See MongoDB Atlas deployment in connection string examples for more:(https://www.mongodb.com/docs/manual/reference/connection-string/)

如何将MongoDB Atlas Uri添加到Python Eve应用

鲜肉鲜肉永远不皱 2025-02-04 00:53:35

您有两种解决此问题的方法。

1。将mainfronandom设置为随机组件

const compDisplay = () => {
        const randomDisplay = Math.floor(Math.random()*data.length);
        setMainFrontRandom(randomDisplay)
    }


}

2。从数据中渲染组件并使用Mainfrontrandom的索引​​

    <>
        <BrowserRouter>
            <Navbar />
            {/* <MainFrontOne/>  */}
            {/* <MainFrontTwo/>  */}
            {/* <MainFrontThree/>  */}
            {
                data[mainFrontRandom] <--- this changed
            }
            <Routes>
                <Route path="/" element={<Enterprice />}/>
                <Route path="enterprice" element={<Enterprice />}/>
                <Route path="developers" element={<Developers />}/>
                <Route path="community" element={<Community />}/>
                <Route path="download" element={<Download />}/>
                <Route path="sign-up" element={<SignUp />}/>
                <Route path="marketing" element={<Marketing />}/>
                <Route path="consulting" element={<Consulting />}/>
            </Routes>
        </BrowserRouter>
    </>


}

You have two ways to fix this problem.

1. Set the mainFrontRandom to random component

const compDisplay = () => {
        const randomDisplay = Math.floor(Math.random()*data.length);
        setMainFrontRandom(randomDisplay)
    }

)
}

2. Render the component from data and use index of mainFrontRandom

    <>
        <BrowserRouter>
            <Navbar />
            {/* <MainFrontOne/>  */}
            {/* <MainFrontTwo/>  */}
            {/* <MainFrontThree/>  */}
            {
                data[mainFrontRandom] <--- this changed
            }
            <Routes>
                <Route path="/" element={<Enterprice />}/>
                <Route path="enterprice" element={<Enterprice />}/>
                <Route path="developers" element={<Developers />}/>
                <Route path="community" element={<Community />}/>
                <Route path="download" element={<Download />}/>
                <Route path="sign-up" element={<SignUp />}/>
                <Route path="marketing" element={<Marketing />}/>
                <Route path="consulting" element={<Consulting />}/>
            </Routes>
        </BrowserRouter>
    </>

)
}

如何将随机组件放入React JS中?

鲜肉鲜肉永远不皱 2025-02-03 16:19:42

如果数据是字符串:

df.loc[df['flow'].ne('sequence'), 'flow'] += df['data'].str.extract('(\d+)',
                                                                    expand=False)

如果是浮点:

df.loc[df['flow'].ne('sequence'), 'flow'] += df['data'].astype(int).astype(str)

输出:

    data       flow
0    1.5  parallel1
1    1.2  parallel1
2    1.3  parallel1
3    2.0   sequence
4    2.5  parallel2
5    2.4  parallel2
6    2.8  parallel2
7    3.0   sequence
8    3.2  parallel3
9    3.1  parallel3
10   3.5  parallel3
11   4.0   sequence
12   4.1  parallel4
13   4.5  parallel4
14   4.3  parallel4
15   1.0   sequence
16   5.0   sequence
17   6.0   sequence

If data is a string:

df.loc[df['flow'].ne('sequence'), 'flow'] += df['data'].str.extract('(\d+)',
                                                                    expand=False)

if it is a float:

df.loc[df['flow'].ne('sequence'), 'flow'] += df['data'].astype(int).astype(str)

output:

    data       flow
0    1.5  parallel1
1    1.2  parallel1
2    1.3  parallel1
3    2.0   sequence
4    2.5  parallel2
5    2.4  parallel2
6    2.8  parallel2
7    3.0   sequence
8    3.2  parallel3
9    3.1  parallel3
10   3.5  parallel3
11   4.0   sequence
12   4.1  parallel4
13   4.5  parallel4
14   4.3  parallel4
15   1.0   sequence
16   5.0   sequence
17   6.0   sequence

根据Python中的浮动值分开数据框

鲜肉鲜肉永远不皱 2025-02-03 14:23:55

解决此问题的最佳方法是使用2-D numpy数组(在这种情况下为列数组)作为 Original 函数的输入结果,我相信您期望的。

这是代码中的外观:

import numpy as np
def f(x):
    return x*np.array([1, 1, 1, 1, 1], dtype=np.float32)

a = np.arange(4).reshape((4, 1))
b = f(a)
# b is a 2-D array with shape (4, 5)
print(b)

这是一种更简单,更少的错误方法来完成操作。该方法并没有尝试用numpy.vectorize转换功能,而是依赖于Numpy自然广播数组的能力。诀窍是确保在数组之间至少一个维度具有相等的长度。

The best way to solve this would be to use a 2-D NumPy array (in this case a column array) as an input to the original function, which will then generate a 2-D output with the results I believe you were expecting.

Here is what it might look like in code:

import numpy as np
def f(x):
    return x*np.array([1, 1, 1, 1, 1], dtype=np.float32)

a = np.arange(4).reshape((4, 1))
b = f(a)
# b is a 2-D array with shape (4, 5)
print(b)

This is a much simpler and less error prone way to complete the operation. Rather than trying to transform the function with numpy.vectorize, this method relies on NumPy's natural ability to broadcast arrays. The trick is to make sure that at least one dimension has an equal length between the arrays.

在返回向量的函数上使用numpy vectorize

鲜肉鲜肉永远不皱 2025-02-03 11:53:43

您也可以使用简单的parseint功能...如果条件
例如

if (parseInt(i)){
    (i in dic) ? dic[i] += 1 : dic[i] = 1
}

You can also use a simple parseInt function too... with an if the condition
for example

if (parseInt(i)){
    (i in dic) ? dic[i] += 1 : dic[i] = 1
}

如何检查字符串是否是有效的数字?

鲜肉鲜肉永远不皱 2025-02-03 00:14:06

您可以使用 params 字段访问 getServersideProps 的上下文访问路由参数。

params :如果此页面使用“ noreferrer”>“动态路由” 参数包含路由参数。如果页面名称为 [id] .js ,则 params 看起来像 {id:...}

- next.js获取:getServersideProps,上下文参数

export async function getServerSideProps(context) {
    const id = context.params.id // Get ID from slug `/book/1`
    
    // Rest of `getServerSideProps` code
}

另外,您还可以使用 Query 字段访问路由参数。区别在于 QUERY 还将包含URL中传递的任何查询参数。

export async function getServerSideProps(context) {
    const id = context.query.id // Get ID from slug `/book/1`
    // If routing to `/book/1?name=some-book`
    console.log(context.query) // Outputs: `{ id: '1', name: 'some-book' }`

    // ...
}

You can access the route parameters through getServerSideProps's context, using the params field.

params: If this page uses a dynamic route, params contains the route parameters. If the page name is [id].js, then params will look like { id: ... }.

Next.js, Data Fetching: getServerSideProps, Context parameter

export async function getServerSideProps(context) {
    const id = context.params.id // Get ID from slug `/book/1`
    
    // Rest of `getServerSideProps` code
}

Alternatively, you can also use the query field to access the route parameters. The difference is that query will also contain any query parameter passed in the URL.

export async function getServerSideProps(context) {
    const id = context.query.id // Get ID from slug `/book/1`
    // If routing to `/book/1?name=some-book`
    console.log(context.query) // Outputs: `{ id: '1', name: 'some-book' }`

    // ...
}

如何在Next.js中访问getererversideprops Insive otar参数?

鲜肉鲜肉永远不皱 2025-02-02 00:01:13

我正在删除以前的字符,将“#”视为一个backspace角色。我已经使用堆栈来构建字符串。

您可以在没有其他空间的情况下执行此操作,例如 std :: stack

std::string buildString(const std::string& s) {
  std::string result;
    for(auto a : s) {
        if(a != '#') {
            result += a;
        } 
        else if(result.size()){
            result.pop_back();
        }
    }

    return result;
}

I'm deleting a previous character considering '#' as a backspace character. I have used stack to build the string.

You could do this without additional space like std::stack:

std::string buildString(const std::string& s) {
  std::string result;
    for(auto a : s) {
        if(a != '#') {
            result += a;
        } 
        else if(result.size()){
            result.pop_back();
        }
    }

    return result;
}

算法将std :: stack转换为std :: string c&#x2b;&#x2B; STL

鲜肉鲜肉永远不皱 2025-02-01 15:04:31

当您发送2个响应时,此错误会发生。例如:

if(condition A)
{ 

      res.render('Profile', {client:client_});

}

if (condition B){

      res.render('Profile', {client:client_});
    }
  }

想象一下是否出于某种原因A和B是否为true,因此在第二个 Render 中您会收到该错误

This error happens when you send 2 responses. For example :

if(condition A)
{ 

      res.render('Profile', {client:client_});

}

if (condition B){

      res.render('Profile', {client:client_});
    }
  }

Imagine if for some reason condition A and B are true so in the second render you'll get that error

错误:将标题发送给客户端后可以设置标头

鲜肉鲜肉永远不皱 2025-02-01 14:20:22

更新:尽管这是提供的唯一工作解决方案 - 请阅读评论线程。有反对这个的好论点。此外,这需要关于写作和部署供应商软件包的强大工作知识。具体来说,当发布更好的解决方案或修复了问题的软件包时,您将需要知道如何回滚。

在您的作曲家项目或软件包中添加一个小PHP文件。

composer.json

{
    ... 
    "autoload": {
        ...
        "files": ["tweak_ini.php"]
    }
}

tweak_ini.php

显然您需要添加一些逻辑以确保您不降级。

ini_set('memory_limit','1000M');
...

UPDATE: Although this is the only working solution provided - please read the comment thread. There are good arguments against this. Also, this requires strong working knowledge of writing and deploying vendor packages. Specifically, you'll want to know how to roll this back when a better solution is posted or the problematic package is fixed.

Add a little php file to your composer project or package.

composer.json

{
    ... 
    "autoload": {
        ...
        "files": ["tweak_ini.php"]
    }
}

tweak_ini.php

Obviously you'll want to add some logic to make sure you aren't downgrading.

ini_set('memory_limit','1000M');
...

我可以在作曲家JSON中指定PHP内存限制要求吗?也许在“ config.platform”中节点?

鲜肉鲜肉永远不皱 2025-02-01 07:39:35

应该关闭:

Sub Data()
    Const SAVE_PATH As String = "C:/VB Code/New folder/"
    
    Dim WB1 As Workbook, WB2 As Workbook, WB3 As Workbook, WB4 As Workbook
    Dim Temp As Workbook, fName As String
    
    Application.DisplayAlerts = False
    
    Set WB1 = Workbooks.Open("C:/VB Code/WB1 Master.xlsm")
    Set WB2 = Workbooks.Open("C:/VB Code/WB2 Master.xlsx")
    Set WB3 = Workbooks.Open("C:/VB Code/WB3 Master.xlsx")
    Set WB4 = Workbooks.Open("C:/VB Code/WB4 Master.xlsx.xlsx")
    Set Temp = Workbooks.Open("C:/VB Code/Template_Blank.xlsm")
    
    CopyValues WB1.Sheets("Analysis").Range("J1"), Temp.Sheets("PPT").Range("B1")
    CopyValues WB1.Sheets("Analysis").Range("A11:M71"), Temp.Sheets("Data").Range("B4")
    CopyValues WB2.Sheets("Analysis").Range("B17:M17"), Temp.Sheets("Data").Range("X27")
    CopyValues WB3.Sheets("Analysis").Range("B9:M9"), Temp.Sheets("Data").Range("X37")
    CopyValues WB4.Sheets("Analysis").Range("B6:B17"), Temp.Sheets("Data").Range("X16")
    
    Temp.Activate
    Temp.RefreshAll
    
    With Temp.Sheets("PPT")
        .Select
        .Range("A1").Activate
        fName = .Range("B1") & ".xlsm"
    End With
    
    Temp.SaveAs Filename:=SAVE_PATH & fName
    
    Application.Run "'" & Temp.Name & "'!CreatePPT" 'run Sub in saved file...
       
    Application.DisplayAlerts = True

End Sub

'utility sub for copying values from `rngFrom` to `rngTo`
Sub CopyValues(rngFrom As Range, rngTo As Range)
    With rngFrom
        rngTo.Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
End Sub

application.run - htttps: //www.rondebruin.nl/win/s9/win001.htm

Should be close:

Sub Data()
    Const SAVE_PATH As String = "C:/VB Code/New folder/"
    
    Dim WB1 As Workbook, WB2 As Workbook, WB3 As Workbook, WB4 As Workbook
    Dim Temp As Workbook, fName As String
    
    Application.DisplayAlerts = False
    
    Set WB1 = Workbooks.Open("C:/VB Code/WB1 Master.xlsm")
    Set WB2 = Workbooks.Open("C:/VB Code/WB2 Master.xlsx")
    Set WB3 = Workbooks.Open("C:/VB Code/WB3 Master.xlsx")
    Set WB4 = Workbooks.Open("C:/VB Code/WB4 Master.xlsx.xlsx")
    Set Temp = Workbooks.Open("C:/VB Code/Template_Blank.xlsm")
    
    CopyValues WB1.Sheets("Analysis").Range("J1"), Temp.Sheets("PPT").Range("B1")
    CopyValues WB1.Sheets("Analysis").Range("A11:M71"), Temp.Sheets("Data").Range("B4")
    CopyValues WB2.Sheets("Analysis").Range("B17:M17"), Temp.Sheets("Data").Range("X27")
    CopyValues WB3.Sheets("Analysis").Range("B9:M9"), Temp.Sheets("Data").Range("X37")
    CopyValues WB4.Sheets("Analysis").Range("B6:B17"), Temp.Sheets("Data").Range("X16")
    
    Temp.Activate
    Temp.RefreshAll
    
    With Temp.Sheets("PPT")
        .Select
        .Range("A1").Activate
        fName = .Range("B1") & ".xlsm"
    End With
    
    Temp.SaveAs Filename:=SAVE_PATH & fName
    
    Application.Run "'" & Temp.Name & "'!CreatePPT" 'run Sub in saved file...
       
    Application.DisplayAlerts = True

End Sub

'utility sub for copying values from `rngFrom` to `rngTo`
Sub CopyValues(rngFrom As Range, rngTo As Range)
    With rngFrom
        rngTo.Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
End Sub

Good resource for Application.Run - https://www.rondebruin.nl/win/s9/win001.htm

saveas .xlsx,然后打开相同的保存文件(从另一个保存的工作簿中调用宏)

鲜肉鲜肉永远不皱 2025-02-01 02:53:54

此问题的熟悉方法是通过使用服务主体 来执行“ 获取Azure AD令牌”。

  1. 在Azure Portal中执行提供服务校长。
  2. 获取广告访问令牌。
  3. 使用服务主体的Azure AD访问令牌访问Databricks REST API

检查以下文档,以获取逐步的过程。

The familiar approach for this problem is performing "Get Azure AD tokens by using a service principal".

  1. Performing provisioning a service principal in Azure Portal.
  2. Get AD access tokens.
  3. Use the service principal’s Azure AD access token to access the Databricks REST API

Check the below documentation for step by step procedure.

https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token#main

Azure数据库的Postman Auth Service主席

鲜肉鲜肉永远不皱 2025-01-31 23:02:49

尽管依赖性_ON,您的服务启动速度比MySQL快,这不知道如何检查容器是否准备好接受连接。您可以在服务Dockerfile中实现等待行为,也可以在Java中执行此类操作:

public static void main(final String[] args) {
    waitForServer("mysqldb", 3306, 10_000);
}

public static void waitForServer(String host, int port, int timeout) {
    long start = System.currentTimeMillis();
    while (portUnavailable(host, port)) {
        System.out.println("Waiting for port to open: " + port);
        if (System.currentTimeMillis() - start > timeout) {
            throw new Error("Timeout waiting for port to open: " + port);
        }
    }
}

private static boolean portUnavailable(String host, int port) {
    try (Socket s = new Socket(host, port)) {
        return false;
    } catch (Exception e) {
        return true;
    }
}

Your service starts faster than MySql despite depends_on which does not know how to check if a container is ready to accept connections. You could implement a wait behaviour in your service Dockerfile or you could do something like this in Java:

public static void main(final String[] args) {
    waitForServer("mysqldb", 3306, 10_000);
}

public static void waitForServer(String host, int port, int timeout) {
    long start = System.currentTimeMillis();
    while (portUnavailable(host, port)) {
        System.out.println("Waiting for port to open: " + port);
        if (System.currentTimeMillis() - start > timeout) {
            throw new Error("Timeout waiting for port to open: " + port);
        }
    }
}

private static boolean portUnavailable(String host, int port) {
    try (Socket s = new Socket(host, port)) {
        return false;
    } catch (Exception e) {
        return true;
    }
}

Docker撰写Java应用程序&amp; JDBC的MySQL连接问题

鲜肉鲜肉永远不皱 2025-01-31 20:10:21

如果您有一个仅在某些情况下定义的对象,则必须向Terraform解释模块的其他部分应对该对象不存在的对象。

在您的情况下,您的IAM策略可能会根据条件 var.policy_name!=“”? 1:0 。但是,您有另一个只有在策略确实存在的情况下才能存在的资源,因此Terraform正确返回了一个错误,说明您无法参考不存在的策略的ARN。

由于 aws_iam_group_policy_attachment 的含义是在IAM组和IAM策略之间建立关系,因此您可能需要为每对组和策略的每个资源类型的实例。表示这种关系的典型方法是与,它在另外两组中计算一组元素组合。

例如:

resource "aws_iam_group_policy_attachment" "test-attach" {
 for_each = {
   for pair in setproduct(toset(var.name), toset(aws_iam_policy.prueba)) :
   "${pair[0]}:${pair[1].name}" => {
     group_name = pair[0]
     policy_arn = pair[1].arn
   }
 }

 group      = each.value.group_name
 policy_arn = each.value.policy_arn
}

for_each 表达式比您启动的组件要多得多,因此我将尝试总结每个部分在做什么:

  • {for ... in ... in ...:::: ... =&gt; ...} 部分是 for for 表达式,它允许从另一个收集值得出一个收集值。在这种情况下,源集合是 setProduct 结果。
  • setProduct(...)采用一个或多个集值,并返回一组新的元组,代表给定集中元素的所有组合。在这种情况下,它返回一组 [group_name,polition_object] 对,其中 group_name var.name 和< group_name 代码> polition_object 是代表 aws_iam_policy.prueba 的对象。
  • for_each 需要为指定为地图密钥的每个实例一个唯一的密钥,因此表达式的是将一组元组转换为图的地图,在该地图中,通过组合一个键来构建键具有策略名称的组名称,每个值都是描述一个相关组名称和一个相关策略ARN的对象。
  • 由于 ever.value 在该资源块中始终是指从结果映射中的值之一,因此我们可以参考 every.value.group_name and code> and every.value .policy_arn 填充单个实例的特定配对。

请注意, setProduct 始终返回一个元素数量的集合,其元素是给定集中元素数量的乘法,因此,如果它们中的任何一个的元素都为零元素,则结果将具有零元素 - 零乘以任何东西都是零。然后最终避免了您在这里遇到的问题,因为如果您的组为零零策略,那么您的附件将零。

If you have an object that is only defined in certain situations then you must explain to Terraform how other parts of the module should react to that object not being present.

In your case you have an IAM policy that may or may not exist depending on the condition var.policy_name != "" ? 1 : 0. However, you have another resource which can only exist if the policy does, and so Terraform correctly returned an error explaining that you cannot refer to the ARN of a policy that doesn't exist.

Since the meaning of aws_iam_group_policy_attachment is to create a relationship between an IAM group and an IAM policy, you presumably need an instance of that resource type for every pair of group and policy. A typical way to represent that relationship is with the setproduct function, which computes a set of all of the combinations of elements in two other sets.

For example:

resource "aws_iam_group_policy_attachment" "test-attach" {
 for_each = {
   for pair in setproduct(toset(var.name), toset(aws_iam_policy.prueba)) :
   "${pair[0]}:${pair[1].name}" => {
     group_name = pair[0]
     policy_arn = pair[1].arn
   }
 }

 group      = each.value.group_name
 policy_arn = each.value.policy_arn
}

This for_each expression has considerably more components than the one you started with, so I will try to summarize what each part is doing:

  • The { for ... in ... : ... => ...} part is a for expression, which allows deriving one collection value from another collection value. In this case, the source collection is the setproduct result.
  • setproduct(...) takes one or more set values and returns a new set of tuples representing all of the combinations of elements in the given sets. In this case, it returns a set of [ group_name, policy_object ] pairs, where group_name is one of the elements from var.name and policy_object is the object representing one of the instances of aws_iam_policy.prueba.
  • for_each requires a unique key for each instance specified as a map key, and so the for expression is transforming that set of tuples into a map where the keys are built from combining a group name with a policy name, and the values are each an object that describes the one relevant group name and the one relevant policy ARN.
  • Since each.value inside that resource block always refers to one of the values from that resulting map, we can refer to each.value.group_name and each.value.policy_arn to populate the specific pairing of those for a single instance.

Note that setproduct always returns a set whose number of elements is the multiplication of the number of elements in the given sets, and so if either of them has zero elements the result will have zero elements -- zero multiplied by anything is zero. That then ultimately avoids the problem you encountered here, because if you have either zero groups or zero policies then you will have zero attachments.

我该怎么做,以便在我想要的时候没有附加政策

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文